xref: /illumos-gate/usr/src/lib/libadutils/common/addisc.h (revision d0f40dc6a997c84bacf5f9ba83d57a95495c399b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef	_ADINFO_H
27 #define	_ADINFO_H
28 
29 #include <rpcsvc/idmap_prot.h>
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Maximum string SID size. 4 bytes for "S-1-", 15 for 2^48 (max authority),
38  * another '-', and ridcount (max 15) 10-digit RIDs plus '-' in between, plus
39  * a null.
40  */
41 #define	MAXSTRSID		185
42 #define	MAXDOMAINNAME		256
43 
44 typedef struct ad_disc *ad_disc_t;
45 
46 
47 typedef struct ad_disc_domains_in_forest {
48 	char domain[MAXDOMAINNAME];
49 	char sid[MAXSTRSID];
50 	int trusted;			/* This is not used by auto */
51 					/* discovery. It is provided so that */
52 					/* domains in a forest can be marked */
53 					/* as trusted. */
54 } ad_disc_domainsinforest_t;
55 
56 
57 typedef struct ad_disc_trusted_domains {
58 		char domain[MAXDOMAINNAME];
59 		int direction;
60 } ad_disc_trusteddomains_t;
61 
62 enum ad_disc_req {
63 		AD_DISC_PREFER_SITE = 0, /* Prefer Site specific version */
64 		AD_DISC_SITE_SPECIFIC,	/* Request Site specific version */
65 		AD_DISC_GLOBAL		/* Request global version */
66 };
67 
68 ad_disc_t ad_disc_init(void);
69 
70 void ad_disc_fini(ad_disc_t);
71 
72 /*
73  * The following routines auto discover the specific item
74  */
75 char *
76 ad_disc_get_DomainName(ad_disc_t ctx, boolean_t *auto_discovered);
77 
78 idmap_ad_disc_ds_t *
79 ad_disc_get_DomainController(ad_disc_t ctx,
80 		enum ad_disc_req req, boolean_t *auto_discovered);
81 
82 char *
83 ad_disc_get_SiteName(ad_disc_t ctx, boolean_t *auto_discovered);
84 
85 char *
86 ad_disc_get_ForestName(ad_disc_t ctx, boolean_t *auto_discovered);
87 
88 idmap_ad_disc_ds_t *
89 ad_disc_get_GlobalCatalog(ad_disc_t ctx, enum ad_disc_req,
90 				boolean_t *auto_discovered);
91 
92 ad_disc_trusteddomains_t *
93 ad_disc_get_TrustedDomains(ad_disc_t ctx,  boolean_t *auto_discovered);
94 
95 ad_disc_domainsinforest_t *
96 ad_disc_get_DomainsInForest(ad_disc_t ctx,  boolean_t *auto_discovered);
97 
98 
99 /*
100  * The following routines over ride auto discovery with the
101  * specified values
102  */
103 int
104 ad_disc_set_DomainName(ad_disc_t ctx, const char *domainName);
105 
106 int
107 ad_disc_set_DomainController(ad_disc_t ctx,
108 		const idmap_ad_disc_ds_t *domainController);
109 
110 int
111 ad_disc_set_SiteName(ad_disc_t ctx, const char *siteName);
112 
113 int
114 ad_disc_set_ForestName(ad_disc_t ctx, const char *forestName);
115 
116 int
117 ad_disc_set_GlobalCatalog(ad_disc_t ctx,
118 		const idmap_ad_disc_ds_t *globalCatalog);
119 
120 
121 /*
122  * This routine forces all auto discovery item to be recomputed
123  * on request
124  */
125 void ad_disc_refresh(ad_disc_t);
126 
127 /*
128  * This routine marks the end of a discovery cycle and sets
129  * the sanity limits on the time before the next cycle.
130  */
131 void ad_disc_done(ad_disc_t);
132 
133 /* This routine unsets all overridden values */
134 int ad_disc_unset(ad_disc_t ctx);
135 
136 /* This routine test for subnet changes */
137 boolean_t ad_disc_SubnetChanged(ad_disc_t);
138 
139 /* This routine returns the Time To Live for auto discovered items */
140 int ad_disc_get_TTL(ad_disc_t);
141 
142 int ad_disc_compare_ds(idmap_ad_disc_ds_t *ds1, idmap_ad_disc_ds_t *ds2);
143 
144 int ad_disc_compare_trusteddomains(ad_disc_trusteddomains_t *td1,
145 		ad_disc_trusteddomains_t *td2);
146 
147 int ad_disc_compare_domainsinforest(ad_disc_domainsinforest_t *td1,
148 		ad_disc_domainsinforest_t *td2);
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif	/* _ADINFO_H */
155