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.
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.
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]
22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
26 #ifndef _ADUTILS_IMPL_H
27 #define _ADUTILS_IMPL_H
31 #include <sys/types.h>
35 #include "libadutils.h"
41 #define DBG(type, lev) \
42 (ad_debug[AD_DEBUG_##type] >= (lev) || \
43 ad_debug[AD_DEBUG_ALL] >= (lev))
44 extern int ad_debug
[AD_DEBUG_MAX
+ 1];
46 #define ADUTILS_SEARCH_TIMEOUT 3
47 #define ADUTILS_LDAP_OPEN_TIMEOUT 1
50 typedef struct adutils_sid
{
52 uchar_t sub_authority_count
;
53 uint64_t authority
; /* really, 48-bits */
54 uint32_t sub_authorities
[ADUTILS_SID_MAX_SUB_AUTHORITIES
];
60 char name
[MAXDOMAINNAME
];
65 /* A set of DSs for a given AD partition */
67 int num_known_domains
;
68 struct known_domain
*known_domains
;
71 struct adutils_host
*last_adh
;
72 adutils_ad_partition_t partition
; /* Data or global catalog? */
73 /* If this is a reference to DC, this is the base DN for that DC */
77 typedef struct adutils_attr
{
83 /* typedef in libadutils.h */
84 struct adutils_entry
{
86 adutils_attr_t
*attr_nvpairs
;
87 struct adutils_entry
*next
;
90 /* typedef in libadutils.h */
91 struct adutils_result
{
93 adutils_entry_t
*entries
;
97 typedef struct adutils_host
{
98 struct adutils_host
*next
;
99 struct adutils_ad
*owner
; /* ad_t to which this belongs */
100 pthread_mutex_t lock
;
101 LDAP
*ld
; /* LDAP connection */
102 uint32_t ref
; /* ref count */
103 time_t idletime
; /* time since last activity */
104 int dead
; /* error on LDAP connection */
106 * Used to distinguish between different instances of LDAP
107 * connections to this same DS. We need this so we never mix up
108 * results for a given msgID from one connection with those of
109 * another earlier connection where two batch state structures
110 * share this adutils_host object but used different LDAP connections
111 * to send their LDAP searches.
119 /* hardwired to SASL GSSAPI only for now */
123 /* Number of outstanding search requests */
124 uint32_t max_requests
;
125 uint32_t num_requests
;
128 /* A place to put the results of a batched (async) query */
129 typedef struct adutils_q
{
130 const char *edomain
; /* expected domain name */
131 struct adutils_result
**result
; /* The LDAP search result */
133 int msgid
; /* LDAP message ID */
136 /* Batch context structure */
137 struct adutils_query_state
{
138 struct adutils_query_state
*next
;
139 int qsize
; /* Size of queries */
140 int ref_cnt
; /* reference count */
141 pthread_cond_t cv
; /* Condition wait variable */
142 uint32_t qcount
; /* Number of items queued */
143 uint32_t qinflight
; /* how many queries in flight */
144 uint16_t qdead
; /* oops, lost LDAP connection */
145 adutils_host_t
*qadh
; /* LDAP connection */
146 uint64_t qadh_gen
; /* same as qadh->generation */
147 adutils_ldap_res_search_cb ldap_res_search_cb
;
148 void *ldap_res_search_argp
;
149 adutils_q_t queries
[1]; /* array of query results */
152 /* Private routines */
154 char *DN_to_DNS(const char *dn_name
);
156 int adutils_getsid(BerValue
*bval
, adutils_sid_t
*sidp
);
158 char *adutils_sid2txt(adutils_sid_t
*sidp
);
160 int saslcallback(LDAP
*ld
, unsigned flags
, void *defaults
, void *prompts
);
162 int adutils_set_thread_functions(LDAP
*ld
);
164 /* Global logger function */
166 extern adutils_logger logger
;
172 #endif /* _ADUTILS_IMPL_H */