xref: /titanic_52/usr/src/lib/libads/common/dsgetdc.h (revision 4eab410fb63816fe2c0ad0fd18b4c948613f6616)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
14  */
15 
16 /*
17  * Declarations intentionally similar to the MSDN SDK file
18  * winsdk/Include/DsGetDC.h
19  */
20 
21 
22 #ifndef	_ADS_DSGETDC_H
23 #define	_ADS_DSGETDC_H
24 
25 #include <sys/types.h>
26 #include <sys/uuid.h>
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 /*
33  * Flags to passed to DsGetDcName
34  */
35 
36 #define	DS_FORCE_REDISCOVERY		0x00000001
37 
38 #define	DS_DIRECTORY_SERVICE_REQUIRED	0x00000010
39 #define	DS_DIRECTORY_SERVICE_PREFERRED	0x00000020
40 #define	DS_GC_SERVER_REQUIRED		0x00000040
41 #define	DS_PDC_REQUIRED			0x00000080
42 #define	DS_BACKGROUND_ONLY		0x00000100
43 #define	DS_IP_REQUIRED			0x00000200
44 #define	DS_KDC_REQUIRED			0x00000400
45 #define	DS_TIMESERV_REQUIRED		0x00000800
46 #define	DS_WRITABLE_REQUIRED		0x00001000
47 #define	DS_GOOD_TIMESERV_PREFERRED	0x00002000
48 #define	DS_AVOID_SELF			0x00004000
49 #define	DS_ONLY_LDAP_NEEDED		0x00008000
50 
51 
52 #define	DS_IS_FLAT_NAME			0x00010000
53 #define	DS_IS_DNS_NAME			0x00020000
54 
55 #define	DS_RETURN_DNS_NAME		0x40000000
56 #define	DS_RETURN_FLAT_NAME		0x80000000
57 
58 /*
59  * Structure returned from DsGetDcName
60  * NB: Keep same as adspriv_dcinfo
61  */
62 
63 typedef struct _DOMAIN_CONTROLLER_INFO {
64 	char *DomainControllerName;
65 	char *DomainControllerAddress;
66 	uint32_t DomainControllerAddressType;
67 	uuid_t DomainGuid;
68 	char *DomainName;
69 	char *DnsForestName;
70 	uint32_t Flags;
71 	char *DcSiteName;
72 	char *ClientSiteName;
73 	uint8_t _sockaddr[256];
74 } DOMAIN_CONTROLLER_INFO, *PDOMAIN_CONTROLLER_INFO;
75 
76 /*
77  * Values for DomainControllerAddressType
78  */
79 
80 #define	DS_INET_ADDRESS		1
81 #define	DS_NETBIOS_ADDRESS	2
82 
83 /*
84  * Values for returned Flags
85  */
86 
87 #define	DS_PDC_FLAG		0x00000001	/* DC is PDC of Domain */
88 #define	DS_GC_FLAG		0x00000004	/* DC is a GC of forest */
89 #define	DS_LDAP_FLAG		0x00000008	/* supports an LDAP server */
90 #define	DS_DS_FLAG		0x00000010	/* supports a DS and is a */
91 						/*   Domain Controller */
92 #define	DS_KDC_FLAG		0x00000020	/* is running KDC service */
93 #define	DS_TIMESERV_FLAG	0x00000040	/* is running time service */
94 #define	DS_CLOSEST_FLAG		0x00000080	/* DC is in closest site */
95 						/*   to the client */
96 #define	DS_WRITABLE_FLAG	0x00000100	/* DC has a writable DS */
97 #define	DS_GOOD_TIMESERV_FLAG	0x00000200	/* is running time service */
98 						/* (and has clock hardware) */
99 #define	DS_NDNC_FLAG		0x00000400	/* DomainName is non-domain */
100 						/* NC serviced by the */
101 						/* LDAP server */
102 #define	DS_PING_FLAGS		0x0000FFFF	/* Flags returned on ping */
103 
104 #define	DS_DNS_CONTROLLER_FLAG	0x20000000	/* DC Name is a DNS name */
105 #define	DS_DNS_DOMAIN_FLAG	0x40000000	/* DomainName is a DNS name */
106 #define	DS_DNS_FOREST_FLAG	0x80000000	/* ForestName is a DNS name */
107 
108 
109 /*
110  * Function Prototypes
111  */
112 
113 /* Offial API.  Returns an NT error number. */
114 extern int
115 DsGetDcName(const char *ComputerName,
116     const char *DomainName, const struct uuid *DomainGuid,
117     const char *SiteName, uint32_t Flags,
118     DOMAIN_CONTROLLER_INFO **dcinfo);
119 
120 /* internal version of above - returns a detailed NT status */
121 extern uint32_t
122 _DsGetDcName(const char *ComputerName,
123     const char *DomainName, const struct uuid *DomainGuid,
124     const char *SiteName, uint32_t Flags,
125     DOMAIN_CONTROLLER_INFO **dcinfo);
126 
127 extern int
128 DsGetSiteName(
129     const char *ComputerName,
130     char **SiteName);
131 
132 /*
133  * XXX: Others from DsGetDc.h we may want later:
134  * DsValidateSubnetName()
135  * DsAddressToSiteNames()
136  * DsAddressToSiteNamesEx()
137  * DsEnumerateDomainTrusts()
138  * DsGetForestTrustInformation()
139  * DsGetDcSiteCoverage()
140  * DsDeregisterDnsHostRecords()
141  * DsGetDcOpen(), DsGetDcNext(), DsGetDcClose()
142  */
143 
144 /*
145  * Until we can easily allocate a DC Info as one big hunk.
146  * This will free a DC Info returned by DsGetDcName().
147  */
148 extern void
149 DsFreeDcInfo(DOMAIN_CONTROLLER_INFO *);
150 
151 /*
152  * Internal function to force DC Rediscovery.
153  */
154 extern int
155 _DsForceRediscovery(char *domain, int flags);
156 
157 #ifdef	__cplusplus
158 }
159 #endif
160 
161 #endif	/* _ADS_DSGETDC_H */
162