00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SMB_LDAP_H
00023 #define _SMB_LDAP_H
00024
00025 enum ldap_request_tag {
00026 LDAP_TAG_BindRequest = 0,
00027 LDAP_TAG_BindResponse = 1,
00028 LDAP_TAG_UnbindRequest = 2,
00029 LDAP_TAG_SearchRequest = 3,
00030 LDAP_TAG_SearchResultEntry = 4,
00031 LDAP_TAG_SearchResultDone = 5,
00032 LDAP_TAG_ModifyRequest = 6,
00033 LDAP_TAG_ModifyResponse = 7,
00034 LDAP_TAG_AddRequest = 8,
00035 LDAP_TAG_AddResponse = 9,
00036 LDAP_TAG_DelRequest = 10,
00037 LDAP_TAG_DelResponse = 11,
00038 LDAP_TAG_ModifyDNRequest = 12,
00039 LDAP_TAG_ModifyDNResponse = 13,
00040 LDAP_TAG_CompareRequest = 14,
00041 LDAP_TAG_CompareResponse = 15,
00042 LDAP_TAG_AbandonRequest = 16,
00043 LDAP_TAG_SearchResultReference = 19,
00044 LDAP_TAG_ExtendedRequest = 23,
00045 LDAP_TAG_ExtendedResponse = 24
00046 };
00047
00048 enum ldap_auth_mechanism {
00049 LDAP_AUTH_MECH_SIMPLE = 0,
00050 LDAP_AUTH_MECH_SASL = 3
00051 };
00052
00053 #ifndef LDAP_SUCCESS
00054 enum ldap_result_code {
00055 LDAP_SUCCESS = 0,
00056 LDAP_SASL_BIND_IN_PROGRESS = 0x0e,
00057 LDAP_INVALID_CREDENTIALS = 0x31,
00058 LDAP_OTHER = 0x50
00059 };
00060 #endif
00061
00062 struct ldap_Result {
00063 int resultcode;
00064 const char *dn;
00065 const char *errormessage;
00066 const char *referral;
00067 };
00068
00069 struct ldap_attribute {
00070 const char *name;
00071 int num_values;
00072 DATA_BLOB *values;
00073 };
00074
00075 struct ldap_BindRequest {
00076 int version;
00077 const char *dn;
00078 enum ldap_auth_mechanism mechanism;
00079 union {
00080 const char *password;
00081 struct {
00082 const char *mechanism;
00083 DATA_BLOB secblob;
00084 } SASL;
00085 } creds;
00086 };
00087
00088 struct ldap_BindResponse {
00089 struct ldap_Result response;
00090 union {
00091 DATA_BLOB secblob;
00092 } SASL;
00093 };
00094
00095 struct ldap_UnbindRequest {
00096 uint8 __dummy;
00097 };
00098
00099 enum ldap_scope {
00100 LDAP_SEARCH_SCOPE_BASE = 0,
00101 LDAP_SEARCH_SCOPE_SINGLE = 1,
00102 LDAP_SEARCH_SCOPE_SUB = 2
00103 };
00104
00105 enum ldap_deref {
00106 LDAP_DEREFERENCE_NEVER = 0,
00107 LDAP_DEREFERENCE_IN_SEARCHING = 1,
00108 LDAP_DEREFERENCE_FINDING_BASE = 2,
00109 LDAP_DEREFERENCE_ALWAYS
00110 };
00111
00112 struct ldap_SearchRequest {
00113 const char *basedn;
00114 enum ldap_scope scope;
00115 enum ldap_deref deref;
00116 uint32 timelimit;
00117 uint32 sizelimit;
00118 BOOL attributesonly;
00119 char *filter;
00120 int num_attributes;
00121 const char **attributes;
00122 };
00123
00124 struct ldap_SearchResEntry {
00125 const char *dn;
00126 int num_attributes;
00127 struct ldap_attribute *attributes;
00128 };
00129
00130 struct ldap_SearchResRef {
00131 int num_referrals;
00132 const char **referrals;
00133 };
00134
00135 enum ldap_modify_type {
00136 LDAP_MODIFY_NONE = -1,
00137 LDAP_MODIFY_ADD = 0,
00138 LDAP_MODIFY_DELETE = 1,
00139 LDAP_MODIFY_REPLACE = 2
00140 };
00141
00142 struct ldap_mod {
00143 enum ldap_modify_type type;
00144 struct ldap_attribute attrib;
00145 };
00146
00147 struct ldap_ModifyRequest {
00148 const char *dn;
00149 int num_mods;
00150 struct ldap_mod *mods;
00151 };
00152
00153 struct ldap_AddRequest {
00154 const char *dn;
00155 int num_attributes;
00156 struct ldap_attribute *attributes;
00157 };
00158
00159 struct ldap_DelRequest {
00160 const char *dn;
00161 };
00162
00163 struct ldap_ModifyDNRequest {
00164 const char *dn;
00165 const char *newrdn;
00166 BOOL deleteolddn;
00167 const char *newsuperior;
00168 };
00169
00170 struct ldap_CompareRequest {
00171 const char *dn;
00172 const char *attribute;
00173 const char *value;
00174 };
00175
00176 struct ldap_AbandonRequest {
00177 uint32 messageid;
00178 };
00179
00180 struct ldap_ExtendedRequest {
00181 const char *oid;
00182 DATA_BLOB value;
00183 };
00184
00185 struct ldap_ExtendedResponse {
00186 struct ldap_Result response;
00187 const char *name;
00188 DATA_BLOB value;
00189 };
00190
00191 union ldap_Request {
00192 struct ldap_BindRequest BindRequest;
00193 struct ldap_BindResponse BindResponse;
00194 struct ldap_UnbindRequest UnbindRequest;
00195 struct ldap_SearchRequest SearchRequest;
00196 struct ldap_SearchResEntry SearchResultEntry;
00197 struct ldap_Result SearchResultDone;
00198 struct ldap_SearchResRef SearchResultReference;
00199 struct ldap_ModifyRequest ModifyRequest;
00200 struct ldap_Result ModifyResponse;
00201 struct ldap_AddRequest AddRequest;
00202 struct ldap_Result AddResponse;
00203 struct ldap_DelRequest DelRequest;
00204 struct ldap_Result DelResponse;
00205 struct ldap_ModifyDNRequest ModifyDNRequest;
00206 struct ldap_Result ModifyDNResponse;
00207 struct ldap_CompareRequest CompareRequest;
00208 struct ldap_Result CompareResponse;
00209 struct ldap_AbandonRequest AbandonRequest;
00210 struct ldap_ExtendedRequest ExtendedRequest;
00211 struct ldap_ExtendedResponse ExtendedResponse;
00212 };
00213
00214 struct ldap_Control {
00215 const char *oid;
00216 BOOL critical;
00217 DATA_BLOB value;
00218 };
00219
00220 struct ldap_message {
00221 TALLOC_CTX *mem_ctx;
00222 uint32 messageid;
00223 uint8 type;
00224 union ldap_Request r;
00225 int num_controls;
00226 struct ldap_Control *controls;
00227 };
00228
00229 struct ldap_queue_entry {
00230 struct ldap_queue_entry *next, *prev;
00231 int msgid;
00232 struct ldap_message *msg;
00233 };
00234
00235 struct ldap_connection {
00236 TALLOC_CTX *mem_ctx;
00237 int sock;
00238 int next_msgid;
00239 char *host;
00240 uint16 port;
00241 BOOL ldaps;
00242
00243 const char *auth_dn;
00244 const char *simple_pw;
00245
00246
00247 int searchid;
00248
00249
00250 struct ldap_queue_entry *search_entries;
00251
00252
00253 struct ldap_queue_entry *outstanding;
00254 };
00255
00256 #endif