adutils_impl.h revision 2
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _ADUTILS_IMPL_H
2N/A#define _ADUTILS_IMPL_H
2N/A
2N/A#include <stdlib.h>
2N/A#include <stdio.h>
2N/A#include <sys/types.h>
2N/A#include <ldap.h>
2N/A#include <pthread.h>
2N/A#include "addisc.h"
2N/A#include <rpcsvc/idmap_prot.h>
2N/A#include "libadutils.h"
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#define DBG(type, lev) \
2N/A (ad_debug[AD_DEBUG_##type] >= (lev) || \
2N/A ad_debug[AD_DEBUG_ALL] >= (lev))
2N/Aextern int ad_debug[AD_DEBUG_MAX + 1];
2N/A
2N/A#define ADUTILS_SEARCH_TIMEOUT 3
2N/A#define ADUTILS_LDAP_OPEN_TIMEOUT 1
2N/A
2N/A
2N/Atypedef struct adutils_sid {
2N/A uchar_t version;
2N/A uchar_t sub_authority_count;
2N/A uint64_t authority; /* really, 48-bits */
2N/A uint32_t sub_authorities[ADUTILS_SID_MAX_SUB_AUTHORITIES];
2N/A} adutils_sid_t;
2N/A
2N/Astruct adutils_host;
2N/A
2N/Astruct known_domain {
2N/A char name[MAXDOMAINNAME];
2N/A char sid[MAXSTRSID];
2N/A};
2N/A
2N/A
2N/A/* A set of DSs for a given AD partition */
2N/Astruct adutils_ad {
2N/A int num_known_domains;
2N/A struct known_domain *known_domains;
2N/A pthread_mutex_t lock;
2N/A uint32_t ref;
2N/A struct adutils_host *last_adh;
2N/A adutils_ad_partition_t partition; /* Data or global catalog? */
2N/A /* If this is a reference to DC, this is the base DN for that DC */
2N/A char *basedn;
2N/A};
2N/A
2N/Atypedef struct adutils_attr {
2N/A char *attr_name;
2N/A uint_t num_values;
2N/A char **attr_values;
2N/A} adutils_attr_t;
2N/A
2N/A/* typedef in libadutils.h */
2N/Astruct adutils_entry {
2N/A uint_t num_nvpairs;
2N/A adutils_attr_t *attr_nvpairs;
2N/A struct adutils_entry *next;
2N/A};
2N/A
2N/A/* typedef in libadutils.h */
2N/Astruct adutils_result {
2N/A uint_t num_entries;
2N/A adutils_entry_t *entries;
2N/A};
2N/A
2N/A/* A single DS */
2N/Atypedef struct adutils_host {
2N/A struct adutils_host *next;
2N/A struct adutils_ad *owner; /* ad_t to which this belongs */
2N/A pthread_mutex_t lock;
2N/A LDAP *ld; /* LDAP connection */
2N/A uint32_t ref; /* ref count */
2N/A time_t idletime; /* time since last activity */
2N/A int dead; /* error on LDAP connection */
2N/A /*
2N/A * Used to distinguish between different instances of LDAP
2N/A * connections to this same DS. We need this so we never mix up
2N/A * results for a given msgID from one connection with those of
2N/A * another earlier connection where two batch state structures
2N/A * share this adutils_host object but used different LDAP connections
2N/A * to send their LDAP searches.
2N/A */
2N/A uint64_t generation;
2N/A
2N/A /* LDAP DS info */
2N/A char *host;
2N/A int port;
2N/A
2N/A /* hardwired to SASL GSSAPI only for now */
2N/A char *saslmech;
2N/A unsigned saslflags;
2N/A
2N/A /* Number of outstanding search requests */
2N/A uint32_t max_requests;
2N/A uint32_t num_requests;
2N/A} adutils_host_t;
2N/A
2N/A/* A place to put the results of a batched (async) query */
2N/Atypedef struct adutils_q {
2N/A const char *edomain; /* expected domain name */
2N/A struct adutils_result **result; /* The LDAP search result */
2N/A adutils_rc *rc;
2N/A int msgid; /* LDAP message ID */
2N/A} adutils_q_t;
2N/A
2N/A/* Batch context structure */
2N/Astruct adutils_query_state {
2N/A struct adutils_query_state *next;
2N/A int qsize; /* Size of queries */
2N/A int ref_cnt; /* reference count */
2N/A pthread_cond_t cv; /* Condition wait variable */
2N/A uint32_t qcount; /* Number of items queued */
2N/A uint32_t qinflight; /* how many queries in flight */
2N/A uint16_t qdead; /* oops, lost LDAP connection */
2N/A adutils_host_t *qadh; /* LDAP connection */
2N/A uint64_t qadh_gen; /* same as qadh->generation */
2N/A adutils_ldap_res_search_cb ldap_res_search_cb;
2N/A void *ldap_res_search_argp;
2N/A adutils_q_t queries[1]; /* array of query results */
2N/A};
2N/A
2N/A/* Private routines */
2N/A
2N/Achar *DN_to_DNS(const char *dn_name);
2N/A
2N/Aint adutils_getsid(BerValue *bval, adutils_sid_t *sidp);
2N/A
2N/Achar *adutils_sid2txt(adutils_sid_t *sidp);
2N/A
2N/Aint saslcallback(LDAP *ld, unsigned flags, void *defaults, void *prompts);
2N/A
2N/Aint adutils_set_thread_functions(LDAP *ld);
2N/A
2N/A/* Global logger function */
2N/A
2N/Aextern adutils_logger logger;
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _ADUTILS_IMPL_H */