Coverage Report

Created: 2026-07-12 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ldap.c
Line
Count
Source
1
/* Do not modify this file. Changes will be overwritten.                      */
2
/* Generated automatically by the ASN.1 to Wireshark dissector compiler       */
3
/* packet-ldap.c                                                              */
4
/* asn2wrs.py -b -q -L -p ldap -c ./ldap.cnf -s ./packet-ldap-template -D . -O ../.. Lightweight-Directory-Access-Protocol-V3.asn */
5
6
/* packet-ldap.c
7
 * Routines for ldap packet dissection
8
 *
9
* See RFC 3494 (LDAP v2), RFC 4511 (LDAP v3), and RFC 2222 (SASL).
10
 *
11
 * Wireshark - Network traffic analyzer
12
 * By Gerald Combs <gerald@wireshark.org>
13
 * Copyright 1998 Gerald Combs
14
 *
15
 * SPDX-License-Identifier: GPL-2.0-or-later
16
 */
17
18
/*
19
 * This is not a complete implementation. It doesn't handle the full version 3, more specifically,
20
 * it handles only the commands of version 2, but any additional characteristics of the ver3 command are supported.
21
 * It's also missing extensible search filters.
22
 *
23
 * There should probably be a lot more error checking, I simply assume that if we have a full packet, it will be a complete
24
 * and correct packet.
25
 *
26
 * AFAIK, it will handle all messages used by the OpenLDAP 1.2.9 server and libraries which was my goal. I do plan to add
27
 * the remaining commands as time permits but this is not a priority to me. Send me an email if you need it and I'll see what
28
 * I can do.
29
 *
30
 * Doug Nazar
31
 * nazard@dragoninc.on.ca
32
 */
33
34
/*
35
 * 11/11/2002 - Fixed problem when decoding LDAP with desegmentation enabled and the
36
 *              ASN.1 BER Universal Class Tag: "Sequence Of" header is encapsulated across 2
37
 *              TCP segments.
38
 *
39
 * Ronald W. Henderson
40
 * ronald.henderson@cognicaseusa.com
41
 */
42
43
/*
44
 * 20-JAN-2004 - added decoding of MS-CLDAP netlogon RPC
45
 *               using information from the SNIA 2003 conference paper :
46
 *               Active Directory Domain Controller Location Service
47
 *                    by Anthony Liguori
48
 * ronnie sahlberg
49
 */
50
51
/*
52
 * 17-DEC-2004 - added basic decoding for LDAP Controls
53
 * 20-DEC-2004 - added handling for GSS-API encrypted blobs
54
 *
55
 * Stefan Metzmacher <metze@samba.org>
56
 *
57
 * 15-NOV-2005 - Changed to use the asn2wrs compiler
58
 * Anders Broman <anders.broman@ericsson.com>
59
 */
60
61
/*
62
 * 3-AUG-2008 - Extended the cldap support to include all netlogon data types.
63
 *              Updated cldap_netlogon_flags to include Windows 2008 flags
64
 *              Expanded the ntver ldap option with bit field
65
 *
66
 * Gary Reynolds <gazzadownunder@yahoo.co.uk>
67
 */
68
69
/*
70
 * 09-DEC-2009 - Added support for RFC4533
71
 *               Content Synchronization Operation (aka syncrepl)
72
 * 11-DEC-2009 - Added support for IntermediateResponse (LDAP v3 from RFC 4511)
73
 * Mathieu Parent <math.parent@gmail.com>
74
 */
75
76
#include "config.h"
77
78
#include <epan/packet.h>
79
#include <epan/exceptions.h>
80
#include <epan/conversation.h>
81
#include <epan/prefs.h>
82
#include <epan/tap.h>
83
#include <epan/srt_table.h>
84
#include <epan/oids.h>
85
#include <epan/strutil.h>
86
#include <epan/show_exception.h>
87
#include <epan/asn1.h>
88
#include <epan/proto_data.h>
89
#include <epan/expert.h>
90
#include <epan/uat.h>
91
#include <epan/charsets.h>
92
#include <epan/tfs.h>
93
#include <wsutil/str_util.h>
94
#include <wsutil/array.h>
95
#include "packet-frame.h"
96
#include "packet-tcp.h"
97
#include "packet-windows-common.h"
98
#include "packet-dcerpc.h"
99
100
#include "packet-ldap.h"
101
#include "packet-ntlmssp.h"
102
#include "packet-tls.h"
103
#include "packet-tls-utils.h"
104
#include "packet-gssapi.h"
105
#include "packet-acdr.h"
106
107
#include "packet-ber.h"
108
#include "packet-per.h"
109
#include "packet-dns.h"
110
111
void proto_register_ldap(void);
112
void proto_reg_handoff_ldap(void);
113
114
/* Initialize the protocol and registered fields */
115
static int ldap_tap;
116
static int proto_ldap;
117
static int proto_cldap;
118
119
static int hf_ldap_sasl_buffer_length;
120
static int hf_ldap_response_in;
121
static int hf_ldap_response_to;
122
static int hf_ldap_time;
123
static int hf_ldap_guid;
124
125
static int hf_mscldap_ntver_flags;
126
static int hf_mscldap_ntver_flags_v1;
127
static int hf_mscldap_ntver_flags_v5;
128
static int hf_mscldap_ntver_flags_v5ex;
129
static int hf_mscldap_ntver_flags_v5ep;
130
static int hf_mscldap_ntver_flags_vcs;
131
static int hf_mscldap_ntver_flags_vnt4;
132
static int hf_mscldap_ntver_flags_vpdc;
133
static int hf_mscldap_ntver_flags_vip;
134
static int hf_mscldap_ntver_flags_vl;
135
static int hf_mscldap_ntver_flags_vgc;
136
137
static int hf_mscldap_netlogon_ipaddress_family;
138
static int hf_mscldap_netlogon_ipaddress_port;
139
static int hf_mscldap_netlogon_ipaddress;
140
static int hf_mscldap_netlogon_ipaddress_ipv4;
141
static int hf_mscldap_netlogon_ipaddress_zero;
142
static int hf_mscldap_netlogon_opcode;
143
static int hf_mscldap_netlogon_flags;
144
static int hf_mscldap_netlogon_flags_pdc;
145
static int hf_mscldap_netlogon_flags_gc;
146
static int hf_mscldap_netlogon_flags_ldap;
147
static int hf_mscldap_netlogon_flags_ds;
148
static int hf_mscldap_netlogon_flags_kdc;
149
static int hf_mscldap_netlogon_flags_timeserv;
150
static int hf_mscldap_netlogon_flags_closest;
151
static int hf_mscldap_netlogon_flags_writable;
152
static int hf_mscldap_netlogon_flags_good_timeserv;
153
static int hf_mscldap_netlogon_flags_ndnc;
154
static int hf_mscldap_netlogon_flags_fnc;
155
static int hf_mscldap_netlogon_flags_dnc;
156
static int hf_mscldap_netlogon_flags_dns;
157
static int hf_mscldap_netlogon_flags_wdc;
158
static int hf_mscldap_netlogon_flags_rodc;
159
static int hf_mscldap_domain_guid;
160
static int hf_mscldap_forest;
161
static int hf_mscldap_domain;
162
static int hf_mscldap_hostname;
163
static int hf_mscldap_nb_domain_z;
164
static int hf_mscldap_nb_domain;
165
static int hf_mscldap_nb_hostname_z;
166
static int hf_mscldap_nb_hostname;
167
static int hf_mscldap_username_z;
168
static int hf_mscldap_username;
169
static int hf_mscldap_sitename;
170
static int hf_mscldap_clientsitename;
171
static int hf_mscldap_nextclosestsitename;
172
static int hf_mscldap_netlogon_lm_token;
173
static int hf_mscldap_netlogon_nt_token;
174
static int hf_ldap_sid;
175
static int hf_ldap_AccessMask_ADS_CREATE_CHILD;
176
static int hf_ldap_AccessMask_ADS_DELETE_CHILD;
177
static int hf_ldap_AccessMask_ADS_LIST;
178
static int hf_ldap_AccessMask_ADS_SELF_WRITE;
179
static int hf_ldap_AccessMask_ADS_READ_PROP;
180
static int hf_ldap_AccessMask_ADS_WRITE_PROP;
181
static int hf_ldap_AccessMask_ADS_DELETE_TREE;
182
static int hf_ldap_AccessMask_ADS_LIST_OBJECT;
183
static int hf_ldap_AccessMask_ADS_CONTROL_ACCESS;
184
static int hf_ldap_LDAPMessage_PDU;
185
static int hf_ldap_object_security_flag;
186
static int hf_ldap_ancestor_first_flag;
187
static int hf_ldap_public_data_only_flag;
188
static int hf_ldap_incremental_value_flag;
189
static int hf_ldap_oid;
190
static int hf_ldap_gssapi_encrypted_payload;
191
192
static int hf_ldap_SearchControlValue_PDU;        /* SearchControlValue */
193
static int hf_ldap_SortKeyList_PDU;               /* SortKeyList */
194
static int hf_ldap_SortResult_PDU;                /* SortResult */
195
static int hf_ldap_DirSyncControlValue_PDU;       /* DirSyncControlValue */
196
static int hf_ldap_PasswdModifyRequestValue_PDU;  /* PasswdModifyRequestValue */
197
static int hf_ldap_CancelRequestValue_PDU;        /* CancelRequestValue */
198
static int hf_ldap_SyncRequestValue_PDU;          /* SyncRequestValue */
199
static int hf_ldap_SyncStateValue_PDU;            /* SyncStateValue */
200
static int hf_ldap_SyncDoneValue_PDU;             /* SyncDoneValue */
201
static int hf_ldap_SyncInfoValue_PDU;             /* SyncInfoValue */
202
static int hf_ldap_PasswordPolicyResponseValue_PDU;  /* PasswordPolicyResponseValue */
203
static int hf_ldap_messageID;                     /* MessageID */
204
static int hf_ldap_protocolOp;                    /* ProtocolOp */
205
static int hf_ldap_controls;                      /* Controls */
206
static int hf_ldap_bindRequest;                   /* BindRequest */
207
static int hf_ldap_bindResponse;                  /* BindResponse */
208
static int hf_ldap_unbindRequest;                 /* UnbindRequest */
209
static int hf_ldap_searchRequest;                 /* SearchRequest */
210
static int hf_ldap_searchResEntry;                /* SearchResultEntry */
211
static int hf_ldap_searchResDone;                 /* SearchResultDone */
212
static int hf_ldap_searchResRef;                  /* SearchResultReference */
213
static int hf_ldap_modifyRequest;                 /* ModifyRequest */
214
static int hf_ldap_modifyResponse;                /* ModifyResponse */
215
static int hf_ldap_addRequest;                    /* AddRequest */
216
static int hf_ldap_addResponse;                   /* AddResponse */
217
static int hf_ldap_delRequest;                    /* DelRequest */
218
static int hf_ldap_delResponse;                   /* DelResponse */
219
static int hf_ldap_modDNRequest;                  /* ModifyDNRequest */
220
static int hf_ldap_modDNResponse;                 /* ModifyDNResponse */
221
static int hf_ldap_compareRequest;                /* CompareRequest */
222
static int hf_ldap_compareResponse;               /* CompareResponse */
223
static int hf_ldap_abandonRequest;                /* AbandonRequest */
224
static int hf_ldap_extendedReq;                   /* ExtendedRequest */
225
static int hf_ldap_extendedResp;                  /* ExtendedResponse */
226
static int hf_ldap_intermediateResponse;          /* IntermediateResponse */
227
static int hf_ldap_AttributeDescriptionList_item;  /* AttributeDescription */
228
static int hf_ldap_attributeDesc;                 /* AttributeDescription */
229
static int hf_ldap_assertionValue;                /* AssertionValue */
230
static int hf_ldap_type;                          /* AttributeDescription */
231
static int hf_ldap_vals;                          /* SET_OF_AttributeValue */
232
static int hf_ldap_vals_item;                     /* AttributeValue */
233
static int hf_ldap_resultCode;                    /* T_resultCode */
234
static int hf_ldap_matchedDN;                     /* LDAPDN */
235
static int hf_ldap_errorMessage;                  /* ErrorMessage */
236
static int hf_ldap_referral;                      /* Referral */
237
static int hf_ldap_Referral_item;                 /* LDAPURL */
238
static int hf_ldap_Controls_item;                 /* Control */
239
static int hf_ldap_controlType;                   /* ControlType */
240
static int hf_ldap_criticality;                   /* BOOLEAN */
241
static int hf_ldap_controlValue;                  /* T_controlValue */
242
static int hf_ldap_version;                       /* INTEGER_1_127 */
243
static int hf_ldap_name;                          /* LDAPDN */
244
static int hf_ldap_authentication;                /* AuthenticationChoice */
245
static int hf_ldap_simple;                        /* Simple */
246
static int hf_ldap_sasl;                          /* SaslCredentials */
247
static int hf_ldap_ntlmsspNegotiate;              /* T_ntlmsspNegotiate */
248
static int hf_ldap_ntlmsspAuth;                   /* T_ntlmsspAuth */
249
static int hf_ldap_mechanism;                     /* Mechanism */
250
static int hf_ldap_credentials;                   /* Credentials */
251
static int hf_ldap_bindResponse_resultCode;       /* BindResponse_resultCode */
252
static int hf_ldap_bindResponse_matchedDN;        /* T_bindResponse_matchedDN */
253
static int hf_ldap_serverSaslCreds;               /* ServerSaslCreds */
254
static int hf_ldap_baseObject;                    /* LDAPDN */
255
static int hf_ldap_scope;                         /* T_scope */
256
static int hf_ldap_derefAliases;                  /* T_derefAliases */
257
static int hf_ldap_sizeLimit;                     /* INTEGER_0_maxInt */
258
static int hf_ldap_timeLimit;                     /* INTEGER_0_maxInt */
259
static int hf_ldap_typesOnly;                     /* BOOLEAN */
260
static int hf_ldap_filter;                        /* T_filter */
261
static int hf_ldap_searchRequest_attributes;      /* AttributeDescriptionList */
262
static int hf_ldap_and;                           /* T_and */
263
static int hf_ldap_and_item;                      /* T_and_item */
264
static int hf_ldap_or;                            /* T_or */
265
static int hf_ldap_or_item;                       /* T_or_item */
266
static int hf_ldap_not;                           /* T_not */
267
static int hf_ldap_equalityMatch;                 /* T_equalityMatch */
268
static int hf_ldap_substrings;                    /* SubstringFilter */
269
static int hf_ldap_greaterOrEqual;                /* T_greaterOrEqual */
270
static int hf_ldap_lessOrEqual;                   /* T_lessOrEqual */
271
static int hf_ldap_present;                       /* T_present */
272
static int hf_ldap_approxMatch;                   /* T_approxMatch */
273
static int hf_ldap_extensibleMatch;               /* T_extensibleMatch */
274
static int hf_ldap_substringFilter_substrings;    /* T_substringFilter_substrings */
275
static int hf_ldap_substringFilter_substrings_item;  /* T_substringFilter_substrings_item */
276
static int hf_ldap_initial;                       /* LDAPString */
277
static int hf_ldap_any;                           /* LDAPString */
278
static int hf_ldap_final;                         /* LDAPString */
279
static int hf_ldap_matchingRule;                  /* MatchingRuleId */
280
static int hf_ldap_matchValue;                    /* AssertionValue */
281
static int hf_ldap_dnAttributes;                  /* T_dnAttributes */
282
static int hf_ldap_objectName;                    /* LDAPDN */
283
static int hf_ldap_searchResultEntry_attributes;  /* PartialAttributeList */
284
static int hf_ldap_PartialAttributeList_item;     /* PartialAttributeList_item */
285
static int hf_ldap__untag_item;                   /* LDAPURL */
286
static int hf_ldap_object;                        /* LDAPDN */
287
static int hf_ldap_modifyRequest_modification;    /* ModifyRequest_modification */
288
static int hf_ldap_modifyRequest_modification_item;  /* T_modifyRequest_modification_item */
289
static int hf_ldap_operation;                     /* T_operation */
290
static int hf_ldap_modification;                  /* AttributeTypeAndValues */
291
static int hf_ldap_entry;                         /* LDAPDN */
292
static int hf_ldap_attributes;                    /* AttributeList */
293
static int hf_ldap_AttributeList_item;            /* AttributeList_item */
294
static int hf_ldap_newrdn;                        /* RelativeLDAPDN */
295
static int hf_ldap_deleteoldrdn;                  /* BOOLEAN */
296
static int hf_ldap_newSuperior;                   /* LDAPDN */
297
static int hf_ldap_ava;                           /* AttributeValueAssertion */
298
static int hf_ldap_requestName;                   /* LDAPOID */
299
static int hf_ldap_requestValue;                  /* T_requestValue */
300
static int hf_ldap_extendedResponse_resultCode;   /* ExtendedResponse_resultCode */
301
static int hf_ldap_responseName;                  /* ResponseName */
302
static int hf_ldap_response;                      /* OCTET_STRING */
303
static int hf_ldap_intermediateResponse_responseValue;  /* T_intermediateResponse_responseValue */
304
static int hf_ldap_size;                          /* INTEGER */
305
static int hf_ldap_cookie;                        /* OCTET_STRING */
306
static int hf_ldap_SortKeyList_item;              /* SortKeyList_item */
307
static int hf_ldap_attributeType;                 /* AttributeDescription */
308
static int hf_ldap_orderingRule;                  /* MatchingRuleId */
309
static int hf_ldap_reverseOrder;                  /* BOOLEAN */
310
static int hf_ldap_sortResult;                    /* T_sortResult */
311
static int hf_ldap_flags;                         /* DirSyncFlags */
312
static int hf_ldap_maxBytes;                      /* INTEGER */
313
static int hf_ldap_userIdentity;                  /* OCTET_STRING */
314
static int hf_ldap_oldPasswd;                     /* OCTET_STRING */
315
static int hf_ldap_newPasswd;                     /* OCTET_STRING */
316
static int hf_ldap_cancelID;                      /* MessageID */
317
static int hf_ldap_mode;                          /* T_mode */
318
static int hf_ldap_reloadHint;                    /* BOOLEAN */
319
static int hf_ldap_state;                         /* T_state */
320
static int hf_ldap_entryUUID;                     /* SyncUUID */
321
static int hf_ldap_refreshDeletes;                /* BOOLEAN */
322
static int hf_ldap_newcookie;                     /* OCTET_STRING */
323
static int hf_ldap_refreshDelete;                 /* T_refreshDelete */
324
static int hf_ldap_refreshDone;                   /* BOOLEAN */
325
static int hf_ldap_refreshPresent;                /* T_refreshPresent */
326
static int hf_ldap_syncIdSet;                     /* T_syncIdSet */
327
static int hf_ldap_syncUUIDs;                     /* SET_OF_SyncUUID */
328
static int hf_ldap_syncUUIDs_item;                /* SyncUUID */
329
static int hf_ldap_warning;                       /* T_warning */
330
static int hf_ldap_timeBeforeExpiration;          /* INTEGER_0_maxInt */
331
static int hf_ldap_graceAuthNsRemaining;          /* INTEGER_0_maxInt */
332
static int hf_ldap_error;                         /* T_error */
333
334
/* Initialize the subtree pointers */
335
static int ett_ldap;
336
static int ett_ldap_msg;
337
static int ett_ldap_sasl_blob;
338
static int ett_ldap_payload;
339
static int ett_mscldap_netlogon_flags;
340
static int ett_mscldap_ntver_flags;
341
static int ett_mscldap_ipdetails;
342
static int ett_ldap_DirSyncFlagsSubEntry;
343
344
static int ett_ldap_LDAPMessage;
345
static int ett_ldap_ProtocolOp;
346
static int ett_ldap_AttributeDescriptionList;
347
static int ett_ldap_AttributeValueAssertion;
348
static int ett_ldap_Attribute;
349
static int ett_ldap_SET_OF_AttributeValue;
350
static int ett_ldap_LDAPResult;
351
static int ett_ldap_Referral;
352
static int ett_ldap_Controls;
353
static int ett_ldap_Control;
354
static int ett_ldap_BindRequest_U;
355
static int ett_ldap_AuthenticationChoice;
356
static int ett_ldap_SaslCredentials;
357
static int ett_ldap_BindResponse_U;
358
static int ett_ldap_SearchRequest_U;
359
static int ett_ldap_Filter;
360
static int ett_ldap_T_and;
361
static int ett_ldap_T_or;
362
static int ett_ldap_SubstringFilter;
363
static int ett_ldap_T_substringFilter_substrings;
364
static int ett_ldap_T_substringFilter_substrings_item;
365
static int ett_ldap_MatchingRuleAssertion;
366
static int ett_ldap_SearchResultEntry_U;
367
static int ett_ldap_PartialAttributeList;
368
static int ett_ldap_PartialAttributeList_item;
369
static int ett_ldap_SEQUENCE_OF_LDAPURL;
370
static int ett_ldap_ModifyRequest_U;
371
static int ett_ldap_ModifyRequest_modification;
372
static int ett_ldap_T_modifyRequest_modification_item;
373
static int ett_ldap_AttributeTypeAndValues;
374
static int ett_ldap_AddRequest_U;
375
static int ett_ldap_AttributeList;
376
static int ett_ldap_AttributeList_item;
377
static int ett_ldap_ModifyDNRequest_U;
378
static int ett_ldap_CompareRequest_U;
379
static int ett_ldap_ExtendedRequest_U;
380
static int ett_ldap_ExtendedResponse_U;
381
static int ett_ldap_IntermediateResponse_U;
382
static int ett_ldap_SearchControlValue;
383
static int ett_ldap_SortKeyList;
384
static int ett_ldap_SortKeyList_item;
385
static int ett_ldap_SortResult;
386
static int ett_ldap_DirSyncControlValue;
387
static int ett_ldap_PasswdModifyRequestValue;
388
static int ett_ldap_CancelRequestValue;
389
static int ett_ldap_SyncRequestValue;
390
static int ett_ldap_SyncStateValue;
391
static int ett_ldap_SyncDoneValue;
392
static int ett_ldap_SyncInfoValue;
393
static int ett_ldap_T_refreshDelete;
394
static int ett_ldap_T_refreshPresent;
395
static int ett_ldap_T_syncIdSet;
396
static int ett_ldap_SET_OF_SyncUUID;
397
static int ett_ldap_PasswordPolicyResponseValue;
398
static int ett_ldap_T_warning;
399
400
static expert_field ei_ldap_exceeded_filter_length;
401
static expert_field ei_ldap_too_many_filter_elements;
402
403
static dissector_table_t ldap_name_dissector_table;
404
static const char *object_identifier_id; /* LDAP OID */
405
406
static bool do_protocolop;
407
static char     *attr_type;
408
static bool is_binary_attr_type;
409
static bool ldap_found_in_frame;
410
411
15
#define TCP_PORT_RANGE_LDAP             "389,3268" /* 3268 is Windows 2000 Global Catalog */
412
#define TCP_PORT_LDAPS                  636
413
15
#define UDP_PORT_CLDAP                  389
414
415
/* desegmentation of LDAP */
416
static bool ldap_desegment = true;
417
static unsigned global_ldaps_tcp_port = TCP_PORT_LDAPS;
418
static unsigned ssl_port;
419
420
static dissector_handle_t gssapi_handle;
421
static dissector_handle_t gssapi_wrap_handle;
422
static dissector_handle_t ntlmssp_handle;
423
static dissector_handle_t spnego_handle;
424
static dissector_handle_t tls_handle;
425
static dissector_handle_t ldap_handle;
426
static dissector_handle_t cldap_handle;
427
428
static void prefs_register_ldap(void); /* forward declaration for use in preferences registration */
429
430
431
/* different types of rpc calls on top of ms cldap */
432
#define MSCLDAP_RPC_NETLOGON  1
433
434
/* Message type Choice values */
435
static const value_string ldap_ProtocolOp_choice_vals[] = {
436
  {   0, "bindRequest" },
437
  {   1, "bindResponse" },
438
  {   2, "unbindRequest" },
439
  {   3, "searchRequest" },
440
  {   4, "searchResEntry" },
441
  {   5, "searchResDone" },
442
  {   6, "searchResRef" },
443
  {   7, "modifyRequest" },
444
  {   8, "modifyResponse" },
445
  {   9, "addRequest" },
446
  {  10, "addResponse" },
447
  {  11, "delRequest" },
448
  {  12, "delResponse" },
449
  {  13, "modDNRequest" },
450
  {  14, "modDNResponse" },
451
  {  15, "compareRequest" },
452
  {  16, "compareResponse" },
453
  {  17, "abandonRequest" },
454
  {  18, "extendedReq" },
455
  {  19, "extendedResp" },
456
  {  20, "intermediateResponse" },
457
  { 0, NULL }
458
};
459
460
/* Procedure names (used in Service Response Time */
461
const value_string ldap_procedure_names[] = {
462
  {   0, "Bind" },
463
  {   3, "Search" },
464
  {   6, "Modify" },
465
  {   8, "Add" },
466
  {  10, "Delete" },
467
  {  12, "Modrdn" },
468
  {  14, "Compare" },
469
  {  23, "Extended" },
470
  { 0, NULL }
471
};
472
473
#define LOGON_PRIMARY_QUERY             7
474
#define LOGON_PRIMARY_RESPONSE         12
475
#define LOGON_SAM_LOGON_REQUEST        18
476
0
#define LOGON_SAM_LOGON_RESPONSE       19
477
#define LOGON_SAM_PAUSE_RESPONSE       20
478
#define LOGON_SAM_USER_UNKNOWN         21
479
0
#define LOGON_SAM_LOGON_RESPONSE_EX    23
480
#define LOGON_SAM_PAUSE_RESPONSE_EX    24
481
#define LOGON_SAM_USER_UNKNOWN_EX      25
482
483
static const value_string netlogon_opcode_vals[] = {
484
  { LOGON_PRIMARY_QUERY,         "LOGON_PRIMARY_QUERY" },
485
  { LOGON_PRIMARY_RESPONSE,      "LOGON_PRIMARY_RESPONSE" },
486
  { LOGON_SAM_LOGON_REQUEST,     "LOGON_SAM_LOGON_REQUEST" },
487
  { LOGON_SAM_LOGON_RESPONSE,    "LOGON_SAM_LOGON_RESPONSE" },
488
  { LOGON_SAM_PAUSE_RESPONSE,    "LOGON_SAM_PAUSE_RESPONSE" },
489
  { LOGON_SAM_LOGON_RESPONSE_EX, "LOGON_SAM_LOGON_RESPONSE_EX" },
490
  { LOGON_SAM_PAUSE_RESPONSE_EX, "LOGON_SAM_PAUSE_RESPONSE_EX" },
491
  { LOGON_SAM_USER_UNKNOWN_EX,   "LOGON_SAM_USER_UNKNOWN_EX" },
492
  { 0, NULL }
493
};
494
495
0
#define LDAP_NUM_PROCEDURES     24
496
497
static void
498
ldapstat_init(struct register_srt* srt _U_, GArray* srt_array)
499
0
{
500
0
  srt_stat_table *ldap_srt_table;
501
0
  uint32_t i;
502
503
0
  ldap_srt_table = init_srt_table("LDAP Commands", NULL, srt_array, LDAP_NUM_PROCEDURES, NULL, "ldap.protocolOp", NULL);
504
0
  for (i = 0; i < LDAP_NUM_PROCEDURES; i++)
505
0
  {
506
0
    init_srt_table_row(ldap_srt_table, i, val_to_str_const(i, ldap_procedure_names, "<unknown>"));
507
0
  }
508
0
}
509
510
static tap_packet_status
511
ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi, tap_flags_t flags _U_)
512
0
{
513
0
  unsigned i = 0;
514
0
  srt_stat_table *ldap_srt_table;
515
0
  const ldap_call_response_t *ldap=(const ldap_call_response_t *)psi;
516
0
  srt_data_t *data = (srt_data_t *)pldap;
517
518
  /* we are only interested in reply packets */
519
0
  if(ldap->is_request){
520
0
    return TAP_PACKET_DONT_REDRAW;
521
0
  }
522
  /* if we haven't seen the request, just ignore it */
523
0
  if(!ldap->req_frame){
524
0
    return TAP_PACKET_DONT_REDRAW;
525
0
  }
526
527
  /* only use the commands we know how to handle */
528
0
  switch(ldap->protocolOpTag){
529
0
  case LDAP_REQ_BIND:
530
0
  case LDAP_REQ_SEARCH:
531
0
  case LDAP_REQ_MODIFY:
532
0
  case LDAP_REQ_ADD:
533
0
  case LDAP_REQ_DELETE:
534
0
  case LDAP_REQ_MODRDN:
535
0
  case LDAP_REQ_COMPARE:
536
0
  case LDAP_REQ_EXTENDED:
537
0
    break;
538
0
  default:
539
0
    return TAP_PACKET_DONT_REDRAW;
540
0
  }
541
542
0
  ldap_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
543
544
0
  add_srt_table_data(ldap_srt_table, ldap->protocolOpTag, &ldap->req_time, pinfo);
545
0
  return TAP_PACKET_REDRAW;
546
0
}
547
548
/*
549
 * Data structure attached to a conversation, giving authentication
550
 * information from a bind request.
551
 */
552
typedef struct ldap_conv_info_t {
553
  unsigned auth_type;    /* authentication type */
554
  char *auth_mech;    /* authentication mechanism */
555
  uint32_t first_auth_frame;  /* first frame that would use a security layer */
556
  wmem_map_t *unmatched;
557
  wmem_map_t *matched;
558
  bool is_mscldap;
559
  uint32_t num_results;
560
  bool start_tls_pending;
561
  uint32_t start_tls_frame;
562
} ldap_conv_info_t;
563
564
static unsigned
565
ldap_info_hash_matched(const void *k)
566
10
{
567
10
  const ldap_call_response_t *key = (const ldap_call_response_t *)k;
568
569
10
  return key->messageId;
570
10
}
571
572
static int
573
ldap_info_equal_matched(const void *k1, const void *k2)
574
7
{
575
7
  const ldap_call_response_t *key1 = (const ldap_call_response_t*)k1;
576
7
  const ldap_call_response_t *key2 = (const ldap_call_response_t*)k2;
577
578
7
  if( key1->req_frame && key2->req_frame && (key1->req_frame!=key2->req_frame) ){
579
6
    return 0;
580
6
  }
581
  /* a response may span multiple frames
582
  if( key1->rep_frame && key2->rep_frame && (key1->rep_frame!=key2->rep_frame) ){
583
    return 0;
584
  }
585
  */
586
587
1
  return key1->messageId==key2->messageId;
588
7
}
589
590
static unsigned
591
ldap_info_hash_unmatched(const void *k)
592
38
{
593
38
  const ldap_call_response_t *key = (const ldap_call_response_t*)k;
594
595
38
  return key->messageId;
596
38
}
597
598
static int
599
ldap_info_equal_unmatched(const void *k1, const void *k2)
600
16
{
601
16
  const ldap_call_response_t *key1 = (const ldap_call_response_t*)k1;
602
16
  const ldap_call_response_t *key2 = (const ldap_call_response_t*)k2;
603
604
16
  return key1->messageId==key2->messageId;
605
16
}
606
607
608
/* These are the NtVer flags from MS-ADTS section 6.3.1.1
609
 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts
610
 */
611
612
static const true_false_string tfs_ntver_v1 = {
613
  "Client requested version 1 netlogon response",
614
  "Version 1 netlogon response not requested"
615
};
616
617
static const true_false_string tfs_ntver_v5 = {
618
  "Client requested version 5 netlogon response",
619
  "Version 5 netlogon response not requested"
620
};
621
static const true_false_string tfs_ntver_v5ex = {
622
  "Client requested version 5 extended netlogon response",
623
  "Version 5 extended response not requested"
624
};
625
static const true_false_string tfs_ntver_v5ep = {
626
  "Client has requested IP address of the server",
627
  "IP address of server not requested"
628
};
629
static const true_false_string tfs_ntver_vcs = {
630
  "Client has asked for the closest site information",
631
  "Closest site information not requested"
632
};
633
static const true_false_string tfs_ntver_vnt4 = {
634
  "Client is requesting server to avoid NT4 emulation",
635
  "Only full AD DS requested"
636
};
637
static const true_false_string tfs_ntver_vpdc = {
638
  "Client has requested the Primary Domain Controller",
639
  "Primary Domain Controller not requested"
640
};
641
static const true_false_string tfs_ntver_vip = {
642
  "Client has requested IP details (obsolete)",
643
  "IP details not requested (obsolete)"
644
};
645
static const true_false_string tfs_ntver_vl = {
646
  "Client indicated that it is the local machine",
647
  "Client is not the local machine"
648
};static const true_false_string tfs_ntver_vgc = {
649
  "Client has requested a Global Catalog server",
650
  "Global Catalog not requested"
651
};
652
653
/* Stuff for generation/handling of fields for custom AttributeValues */
654
typedef struct _attribute_type_t {
655
  char* attribute_type;
656
  char* attribute_desc;
657
} attribute_type_t;
658
659
static attribute_type_t* attribute_types;
660
static unsigned num_attribute_types;
661
662
static GHashTable* attribute_types_hash;
663
static hf_register_info* dynamic_hf;
664
static unsigned dynamic_hf_size;
665
666
static bool
667
attribute_types_update_cb(void *r, char **err)
668
0
{
669
0
  attribute_type_t *rec = (attribute_type_t *)r;
670
0
  char c;
671
672
0
  if (rec->attribute_type == NULL) {
673
0
    *err = g_strdup("Attribute type can't be empty");
674
0
    return false;
675
0
  }
676
677
0
  g_strstrip(rec->attribute_type);
678
0
  if (rec->attribute_type[0] == 0) {
679
0
    *err = g_strdup("Attribute type can't be empty");
680
0
    return false;
681
0
  }
682
683
  /* Check for invalid characters (to avoid asserting out when
684
   * registering the field).
685
   */
686
0
  c = proto_check_field_name(rec->attribute_type);
687
0
  if (c) {
688
0
    *err = ws_strdup_printf("Attribute type can't contain '%c'", c);
689
0
    return false;
690
0
  }
691
692
0
  *err = NULL;
693
0
  return true;
694
0
}
695
696
static void *
697
attribute_types_copy_cb(void* n, const void* o, size_t siz _U_)
698
0
{
699
0
  attribute_type_t* new_rec = (attribute_type_t*)n;
700
0
  const attribute_type_t* old_rec = (const attribute_type_t*)o;
701
702
0
  new_rec->attribute_type = g_strdup(old_rec->attribute_type);
703
0
  new_rec->attribute_desc = g_strdup(old_rec->attribute_desc);
704
705
0
  return new_rec;
706
0
}
707
708
static void
709
attribute_types_free_cb(void*r)
710
0
{
711
0
  attribute_type_t* rec = (attribute_type_t*)r;
712
713
0
  g_free(rec->attribute_type);
714
0
  g_free(rec->attribute_desc);
715
0
}
716
717
0
UAT_CSTRING_CB_DEF(attribute_types, attribute_type, attribute_type_t)
718
0
UAT_CSTRING_CB_DEF(attribute_types, attribute_desc, attribute_type_t)
719
720
/*
721
 *
722
 */
723
static int*
724
get_hf_for_header(char* attribute_type)
725
0
{
726
0
  int* hf_id = NULL;
727
728
0
  if (attribute_types_hash && attribute_type) {
729
0
    hf_id = (int*) g_hash_table_lookup(attribute_types_hash, attribute_type);
730
0
  } else {
731
0
    hf_id = NULL;
732
0
  }
733
734
0
  return hf_id;
735
0
}
736
737
/*
738
 *
739
 */
740
static void
741
deregister_attribute_types(void)
742
15
{
743
15
  if (dynamic_hf) {
744
    /* Deregister all fields */
745
0
    for (unsigned i = 0; i < dynamic_hf_size; i++) {
746
0
      proto_deregister_field (proto_ldap, *(dynamic_hf[i].p_id));
747
0
      g_free (dynamic_hf[i].p_id);
748
0
    }
749
750
0
    proto_add_deregistered_data (dynamic_hf);
751
0
    dynamic_hf = NULL;
752
0
    dynamic_hf_size = 0;
753
0
  }
754
755
15
  if (attribute_types_hash) {
756
0
    g_hash_table_destroy (attribute_types_hash);
757
0
    attribute_types_hash = NULL;
758
0
  }
759
15
}
760
761
static void
762
attribute_types_post_update_cb(void)
763
15
{
764
15
  int* hf_id;
765
15
  char* attribute_type;
766
767
15
  deregister_attribute_types();
768
769
15
  if (num_attribute_types) {
770
0
    attribute_types_hash = g_hash_table_new(g_str_hash, g_str_equal);
771
0
    dynamic_hf = g_new0(hf_register_info,num_attribute_types);
772
0
    dynamic_hf_size = num_attribute_types;
773
774
0
    for (unsigned i = 0; i < dynamic_hf_size; i++) {
775
0
      hf_id = g_new(int,1);
776
0
      *hf_id = -1;
777
0
      attribute_type = g_strdup(attribute_types[i].attribute_type);
778
779
0
      dynamic_hf[i].p_id = hf_id;
780
0
      dynamic_hf[i].hfinfo.name = attribute_type;
781
0
      dynamic_hf[i].hfinfo.abbrev = ws_strdup_printf("ldap.AttributeValue.%s", attribute_type);
782
0
      dynamic_hf[i].hfinfo.type = FT_STRING;
783
0
      dynamic_hf[i].hfinfo.display = BASE_NONE;
784
0
      dynamic_hf[i].hfinfo.strings = NULL;
785
0
      dynamic_hf[i].hfinfo.bitmask = 0;
786
0
      dynamic_hf[i].hfinfo.blurb = g_strdup(attribute_types[i].attribute_desc);
787
0
      HFILL_INIT(dynamic_hf[i]);
788
789
0
      g_hash_table_insert(attribute_types_hash, attribute_type, hf_id);
790
0
    }
791
792
0
    proto_register_field_array(proto_ldap, dynamic_hf, dynamic_hf_size);
793
0
  }
794
15
}
795
796
static void
797
attribute_types_reset_cb(void)
798
0
{
799
0
  deregister_attribute_types();
800
0
}
801
802
/* MS-ADTS specification, section 6.3.1.1, NETLOGON_NT_VERSION Options Bits */
803
static int dissect_mscldap_ntver_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
804
0
{
805
0
  static int * const flags[] = {
806
0
    &hf_mscldap_ntver_flags_v1,
807
0
    &hf_mscldap_ntver_flags_v5,
808
0
    &hf_mscldap_ntver_flags_v5ex,
809
0
    &hf_mscldap_ntver_flags_v5ep,
810
0
    &hf_mscldap_ntver_flags_vcs,
811
0
    &hf_mscldap_ntver_flags_vnt4,
812
0
    &hf_mscldap_ntver_flags_vpdc,
813
0
    &hf_mscldap_ntver_flags_vip,
814
0
    &hf_mscldap_ntver_flags_vl,
815
0
    &hf_mscldap_ntver_flags_vgc,
816
0
    NULL
817
0
  };
818
819
0
  proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_mscldap_ntver_flags,
820
0
                           ett_mscldap_ntver_flags, flags, ENC_LITTLE_ENDIAN, BMT_NO_FALSE);
821
0
  offset += 4;
822
823
0
  return offset;
824
0
}
825
826
/* This string contains the last LDAPString that was decoded */
827
static const char *attributedesc_string;
828
829
/* This string contains the last AssertionValue that was decoded */
830
static char *ldapvalue_string;
831
832
/* if the octet string contain all printable ASCII characters, then
833
 * display it as a string, othervise just display it in hex.
834
 */
835
static unsigned
836
dissect_ldap_AssertionValue(bool implicit_tag, tvbuff_t *tvb, unsigned offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index)
837
0
{
838
0
  int8_t ber_class;
839
0
  bool pc, ind, is_ascii;
840
0
  int32_t tag;
841
0
  uint32_t len;
842
843
0
  if(!implicit_tag){
844
0
    offset=get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
845
0
    offset=get_ber_length(tvb, offset, &len, &ind);
846
0
  } else {
847
0
    len=tvb_reported_length_remaining(tvb,offset);
848
0
  }
849
850
0
  if(len==0){
851
0
    return offset;
852
0
  }
853
854
855
  /*
856
   * Some special/wellknown attributes in common LDAP (read AD)
857
   * are neither ascii strings nor blobs of hex data.
858
   * Special case these attributes and decode them more nicely.
859
   *
860
   * Add more special cases as required to prettify further
861
   * (there can't be that many ones that are truly interesting)
862
   */
863
0
  if(attributedesc_string && !strncmp("DomainSid", attributedesc_string, 9)){
864
0
    tvbuff_t *sid_tvb;
865
0
    char *tmpstr;
866
867
    /* this octet string contains an NT SID */
868
0
    sid_tvb=tvb_new_subset_length(tvb, offset, len);
869
0
    dissect_nt_sid(sid_tvb, actx->pinfo, 0, tree, "SID", &tmpstr, hf_index);
870
0
    ldapvalue_string=tmpstr;
871
872
0
    goto finished;
873
0
  } else if ( (len==16) /* GUIDs are always 16 bytes */
874
0
  && (attributedesc_string && !strncmp("DomainGuid", attributedesc_string, 10))) {
875
0
    uint8_t drep[4] = { 0x10, 0x00, 0x00, 0x00}; /* fake DREP struct */
876
0
    e_guid_t uuid;
877
878
    /* This octet string contained a GUID */
879
0
    dissect_dcerpc_uuid_t(tvb, offset, actx->pinfo, tree, drep, hf_ldap_guid, &uuid);
880
881
0
    ldapvalue_string=(char*)wmem_alloc(actx->pinfo->pool, 1024);
882
0
    snprintf(ldapvalue_string, 1023, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
883
0
               uuid.data1, uuid.data2, uuid.data3, uuid.data4[0], uuid.data4[1],
884
0
               uuid.data4[2], uuid.data4[3], uuid.data4[4], uuid.data4[5],
885
0
               uuid.data4[6], uuid.data4[7]);
886
887
0
    goto finished;
888
0
  } else if (attributedesc_string && !strncmp("NtVer", attributedesc_string, 5)){
889
0
    uint32_t flags;
890
891
0
    len = 0;
892
    /* get flag value to populate ldapvalue_string */
893
0
    flags=tvb_get_letohl(tvb, offset);
894
895
0
    ldapvalue_string=(char*)wmem_alloc(actx->pinfo->pool, 1024);
896
0
    snprintf(ldapvalue_string, 1023, "0x%08x",flags);
897
898
    /* populate bitmask subtree */
899
0
    offset = dissect_mscldap_ntver_flags(tree, tvb, offset);
900
901
0
    goto finished;
902
903
904
0
  }
905
906
  /*
907
   * It was not one of our "wellknown" attributes so make the best
908
   * we can and just try to see if it is an ascii string or if it
909
   * is a binary blob.
910
   *
911
   * XXX - should we support reading RFC 2252-style schemas
912
   * for LDAP, and using that to determine how to display
913
   * attribute values and assertion values?
914
   *
915
   * -- I don't think there are full schemas available that describe the
916
   *  interesting cases i.e. AD -- ronnie
917
   */
918
0
  is_ascii=tvb_ascii_isprint(tvb, offset, len);
919
920
  /* convert the string into a printable string */
921
0
  if(is_ascii){
922
0
    ldapvalue_string= (char*)tvb_get_string_enc(actx->pinfo->pool, tvb, offset, len, ENC_UTF_8|ENC_NA);
923
0
  } else {
924
0
    ldapvalue_string= tvb_bytes_to_str_punct(actx->pinfo->pool, tvb, offset, len, ':');
925
0
  }
926
927
0
  proto_tree_add_string(tree, hf_index, tvb, offset, len, ldapvalue_string);
928
929
930
0
finished:
931
0
  offset+=len;
932
0
  return offset;
933
0
}
934
935
/* This string contains the last Filter item that was decoded */
936
static const char *Filter_string;
937
static const char *and_filter_string;
938
static const char *or_filter_string;
939
static const char *substring_value;
940
static const char *substring_item_init;
941
static const char *substring_item_any;
942
static const char *substring_item_final;
943
static const char *matching_rule_string;
944
static bool matching_rule_dnattr=false;
945
946
14
#define MAX_FILTER_LEN 4096
947
static int Filter_length;
948
949
14
#define MAX_FILTER_ELEMENTS 200
950
static int Filter_elements;
951
952
/* Global variables */
953
static unsigned MessageID;
954
static int ProtocolOp = -1;
955
static proto_item *ldm_tree; /* item to add text to */
956
957
static void ldap_do_protocolop(packet_info *pinfo)
958
38
{
959
38
  const char* valstr;
960
961
38
  if (do_protocolop) {
962
963
37
    valstr = val_to_str(pinfo->pool, ProtocolOp, ldap_ProtocolOp_choice_vals, "Unknown (%u)");
964
965
37
    col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", valstr, MessageID);
966
967
37
    if(ldm_tree)
968
9
      proto_item_append_text(ldm_tree, " %s(%d)", valstr, MessageID);
969
970
37
    do_protocolop = false;
971
972
37
  }
973
38
}
974
975
static ldap_call_response_t *
976
ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned messageId, unsigned protocolOpTag, ldap_conv_info_t *ldap_info)
977
35
{
978
35
  ldap_call_response_t lcr, *lcrp=NULL;
979
980
  /* first see if we have already matched this */
981
982
35
      lcr.messageId=messageId;
983
35
      switch(protocolOpTag){
984
1
        case LDAP_REQ_BIND:
985
3
        case LDAP_REQ_SEARCH:
986
3
        case LDAP_REQ_MODIFY:
987
3
        case LDAP_REQ_ADD:
988
13
        case LDAP_REQ_DELETE:
989
14
        case LDAP_REQ_MODRDN:
990
15
        case LDAP_REQ_COMPARE:
991
16
        case LDAP_REQ_EXTENDED:
992
16
          lcr.is_request=true;
993
16
          lcr.req_frame=pinfo->num;
994
16
          lcr.rep_frame=0;
995
16
          break;
996
1
        case LDAP_RES_BIND:
997
7
        case LDAP_RES_SEARCH_ENTRY:
998
10
        case LDAP_RES_SEARCH_REF:
999
11
        case LDAP_RES_SEARCH_RESULT:
1000
12
        case LDAP_RES_MODIFY:
1001
12
        case LDAP_RES_ADD:
1002
12
        case LDAP_RES_DELETE:
1003
12
        case LDAP_RES_MODRDN:
1004
13
        case LDAP_RES_COMPARE:
1005
15
        case LDAP_RES_EXTENDED:
1006
17
        case LDAP_RES_INTERMEDIATE:
1007
17
          lcr.is_request=false;
1008
17
          lcr.req_frame=0;
1009
17
          lcr.rep_frame=pinfo->num;
1010
17
          break;
1011
2
        default:
1012
2
          return NULL;
1013
35
      }
1014
33
      lcrp=(ldap_call_response_t *)wmem_map_lookup(ldap_info->matched, &lcr);
1015
1016
33
      if(lcrp){
1017
1018
1
        lcrp->is_request=lcr.is_request;
1019
1020
32
      } else {
1021
1022
        /* we haven't found a match - try and match it up */
1023
1024
32
  switch(protocolOpTag){
1025
1
      case LDAP_REQ_BIND:
1026
3
      case LDAP_REQ_SEARCH:
1027
3
      case LDAP_REQ_MODIFY:
1028
3
      case LDAP_REQ_ADD:
1029
13
      case LDAP_REQ_DELETE:
1030
14
      case LDAP_REQ_MODRDN:
1031
15
      case LDAP_REQ_COMPARE:
1032
16
      case LDAP_REQ_EXTENDED:
1033
1034
        /* this is a request - add it to the unmatched list */
1035
1036
        /* check that we don't already have one of those in the
1037
           unmatched list and if so remove it */
1038
1039
16
        lcr.messageId=messageId;
1040
16
        lcrp=(ldap_call_response_t *)wmem_map_lookup(ldap_info->unmatched, &lcr);
1041
16
        if(lcrp){
1042
5
          wmem_map_remove(ldap_info->unmatched, lcrp);
1043
5
        }
1044
        /* if we can't reuse the old one, grab a new chunk */
1045
16
        if(!lcrp){
1046
11
          lcrp=wmem_new0(wmem_file_scope(), ldap_call_response_t);
1047
11
        }
1048
16
        lcrp->messageId=messageId;
1049
16
        lcrp->req_frame=pinfo->num;
1050
16
        lcrp->req_time=pinfo->abs_ts;
1051
16
        lcrp->rep_frame=0;
1052
16
        lcrp->protocolOpTag=protocolOpTag;
1053
16
        lcrp->is_request=true;
1054
16
        wmem_map_insert(ldap_info->unmatched, lcrp, lcrp);
1055
16
        return NULL;
1056
1
      case LDAP_RES_BIND:
1057
7
      case LDAP_RES_SEARCH_ENTRY:
1058
9
      case LDAP_RES_SEARCH_REF:
1059
10
      case LDAP_RES_SEARCH_RESULT:
1060
11
      case LDAP_RES_MODIFY:
1061
11
      case LDAP_RES_ADD:
1062
11
      case LDAP_RES_DELETE:
1063
11
      case LDAP_RES_MODRDN:
1064
12
      case LDAP_RES_COMPARE:
1065
14
      case LDAP_RES_EXTENDED:
1066
16
      case LDAP_RES_INTERMEDIATE:
1067
1068
      /* this is a result - it should be in our unmatched list */
1069
1070
16
        lcr.messageId=messageId;
1071
16
        lcrp=(ldap_call_response_t *)wmem_map_lookup(ldap_info->unmatched, &lcr);
1072
1073
16
        if(lcrp){
1074
1075
3
          if(!lcrp->rep_frame){
1076
3
            wmem_map_remove(ldap_info->unmatched, lcrp);
1077
3
            lcrp->rep_frame=pinfo->num;
1078
3
            lcrp->is_request=false;
1079
3
            wmem_map_insert(ldap_info->matched, lcrp, lcrp);
1080
3
          }
1081
3
        }
1082
1083
16
        break;
1084
32
      }
1085
1086
32
    }
1087
    /* we have found a match */
1088
1089
17
    if(lcrp){
1090
4
      proto_item *it;
1091
1092
4
      if(lcrp->is_request){
1093
0
        it=proto_tree_add_uint(tree, hf_ldap_response_in, tvb, 0, 0, lcrp->rep_frame);
1094
0
        proto_item_set_generated(it);
1095
4
      } else {
1096
4
        nstime_t ns;
1097
4
        it=proto_tree_add_uint(tree, hf_ldap_response_to, tvb, 0, 0, lcrp->req_frame);
1098
4
        proto_item_set_generated(it);
1099
4
        nstime_delta(&ns, &pinfo->abs_ts, &lcrp->req_time);
1100
4
        it=proto_tree_add_time(tree, hf_ldap_time, tvb, 0, 0, &ns);
1101
4
        proto_item_set_generated(it);
1102
4
      }
1103
4
    }
1104
1105
17
    return lcrp;
1106
33
}
1107
1108
/*--- Cyclic dependencies ---*/
1109
1110
/* Filter -> Filter/and -> Filter/and/_item -> Filter */
1111
/* Filter -> Filter/or -> Filter/or/_item -> Filter */
1112
/* Filter -> Filter/not -> Filter */
1113
static unsigned dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
1114
1115
1116
1117
1118
static unsigned
1119
15
dissect_ldap_MessageID(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1120
1121
15
  offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
1122
15
                                                            0U, maxInt, hf_index, &MessageID);
1123
1124
1125
15
  ldm_tree = tree;
1126
1127
1128
15
  return offset;
1129
15
}
1130
1131
1132
1133
static unsigned
1134
0
dissect_ldap_INTEGER_1_127(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1135
0
  offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
1136
0
                                                            1U, 127U, hf_index, NULL);
1137
1138
0
  return offset;
1139
0
}
1140
1141
1142
1143
static unsigned
1144
29
dissect_ldap_LDAPString(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1145
29
  tvbuff_t  *parameter_tvb = NULL;
1146
29
  const char *ldapstring = NULL;
1147
29
  char *sc = NULL; /* semi-colon pointer */
1148
1149
29
  offset = dissect_ber_octet_string_with_encoding(implicit_tag, actx, tree, tvb, offset, hf_index,
1150
29
                                       &parameter_tvb, ENC_UTF_8|ENC_NA);
1151
1152
29
  if (parameter_tvb || (hf_index == hf_ldap_baseObject)) {
1153
1154
18
  ldap_do_protocolop(actx->pinfo);
1155
1156
18
  if(parameter_tvb)
1157
15
    ldapstring = (char*)tvb_get_string_enc(actx->pinfo->pool, parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb, 0), ENC_UTF_8|ENC_NA);
1158
1159
18
  if(hf_index == hf_ldap_baseObject) {
1160
    /* this is search - put it on the scanline */
1161
4
    if(!ldapstring || !*ldapstring)
1162
3
      ldapstring = "<ROOT>";
1163
1164
4
    col_append_fstr(actx->pinfo->cinfo, COL_INFO, "\"%s\" ", ldapstring);
1165
1166
4
    if(ldm_tree)
1167
0
      proto_item_append_text(ldm_tree, " \"%s\"", ldapstring);
1168
1169
1170
4
    if(!parameter_tvb) {
1171
1172
3
      proto_item_append_text(actx->created_item, " (%s)", ldapstring);
1173
3
    }
1174
1175
14
  } else if ((hf_index == hf_ldap_errorMessage) && ldapstring && *ldapstring) { /* only show message if not success */
1176
1
    col_append_fstr(actx->pinfo->cinfo, COL_INFO, "(%s) ", ldapstring);
1177
1178
1
    if(ldm_tree)
1179
0
      proto_item_append_text(ldm_tree, " (%s)", ldapstring);
1180
1181
13
    } else if ((hf_index == hf_ldap_objectName) ||
1182
13
               (hf_index == hf_ldap_name) ||
1183
13
               (hf_index == hf_ldap_entry) ||
1184
13
               (hf_index == hf_ldap_object) ||
1185
13
               (hf_index == hf_ldap_delRequest) ) {
1186
1187
10
      if(!ldapstring || !*ldapstring)
1188
3
        ldapstring = "<ROOT>";
1189
1190
10
      col_append_fstr(actx->pinfo->cinfo, COL_INFO, "\"%s\" ", ldapstring);
1191
1192
10
      if(ldm_tree)
1193
0
        proto_item_append_text(ldm_tree, " \"%s\"", ldapstring);
1194
10
      } else if (hf_index == hf_ldap_attributeDesc){
1195
        /* remember the attribute description */
1196
0
        attributedesc_string=ldapstring;
1197
3
      } else if (hf_index == hf_ldap_initial){
1198
        /* remember the substring item */
1199
0
        substring_item_init=ldapstring;
1200
3
      } else if (hf_index == hf_ldap_any){
1201
        /* remember the substring item */
1202
0
        substring_item_any=ldapstring;
1203
3
      } else if (hf_index == hf_ldap_final){
1204
        /* remember the substring item */
1205
0
        substring_item_final=ldapstring;
1206
3
      } else if (hf_index == hf_ldap_matchingRule){
1207
        /* remember the matching rule */
1208
0
        matching_rule_string=ldapstring;
1209
3
      } else if (hf_index == hf_ldap_present){
1210
        /* remember the present name */
1211
0
        Filter_string=ldapstring;
1212
3
      } else if (hf_index == hf_ldap_type) {
1213
        /* remember attribute type name */
1214
0
        attr_type = wmem_strdup(actx->pinfo->pool, ldapstring);
1215
1216
        /* append it to the parent entry */
1217
0
        proto_item_append_text(tree, " %s", attr_type);
1218
1219
        /* remove the ";binary" component if present */
1220
0
        if((sc = strchr(attr_type, ';')) != NULL) {
1221
0
          if(!strcmp(sc, ";binary")) {
1222
0
            *sc = '\0'; /* terminate the string */
1223
0
            is_binary_attr_type = true;
1224
0
          }
1225
0
        } else {
1226
0
          is_binary_attr_type = false;
1227
0
        }
1228
0
    }
1229
1230
18
  }
1231
1232
1233
29
  return offset;
1234
29
}
1235
1236
1237
1238
static unsigned
1239
26
dissect_ldap_LDAPDN(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1240
26
  offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
1241
1242
26
  return offset;
1243
26
}
1244
1245
1246
1247
static unsigned
1248
0
dissect_ldap_Simple(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1249
0
ldap_conv_info_t *ldap_info;
1250
1251
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1252
0
                                       NULL);
1253
1254
1255
0
  ldap_info = (ldap_conv_info_t *)actx->private_data;
1256
0
  ldap_info->auth_type = LDAP_AUTH_SIMPLE;
1257
1258
1259
0
  return offset;
1260
0
}
1261
1262
1263
1264
static unsigned
1265
0
dissect_ldap_Mechanism(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1266
1267
0
ldap_conv_info_t *ldap_info;
1268
0
tvbuff_t  *parameter_tvb;
1269
0
char *mechanism = NULL;
1270
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1271
0
                                       &parameter_tvb);
1272
1273
0
  ldap_info = (ldap_conv_info_t *)actx->private_data;
1274
0
  ldap_info->auth_type = LDAP_AUTH_SASL;
1275
1276
0
  if (!parameter_tvb)
1277
0
    return offset;
1278
1279
  /*
1280
   * We need to remember the authentication type and mechanism for this
1281
   * conversation.
1282
   *
1283
   * XXX - actually, we might need to remember more than one
1284
   * type and mechanism, if you can unbind and rebind with a
1285
   * different type and/or mechanism.
1286
   */
1287
0
  if(!actx->pinfo->fd->visited) {
1288
0
    mechanism = (char*)tvb_get_string_enc(wmem_file_scope(), parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
1289
0
    ldap_info->first_auth_frame = 0; /* not known until we see the bind reply */
1290
    /*
1291
     * If the mechanism in this request is an empty string (which is
1292
     * returned as a null pointer), use the saved mechanism instead.
1293
     * Otherwise, if the saved mechanism is an empty string (null),
1294
     * save this mechanism.
1295
    */
1296
0
    if (mechanism != NULL) {
1297
0
      wmem_free(wmem_file_scope(), ldap_info->auth_mech);
1298
0
      ldap_info->auth_mech = mechanism;
1299
0
    }
1300
0
  }
1301
1302
0
  return offset;
1303
0
}
1304
1305
1306
1307
static unsigned
1308
0
dissect_ldap_Credentials(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1309
1310
0
tvbuff_t *parameter_tvb;
1311
0
ldap_conv_info_t *ldap_info;
1312
0
int8_t ber_class;
1313
0
bool pc;
1314
0
int32_t tag;
1315
1316
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1317
0
                                       &parameter_tvb);
1318
1319
1320
0
  if (!parameter_tvb)
1321
0
    return offset;
1322
1323
0
  ldap_info = (ldap_conv_info_t *)actx->private_data;
1324
0
  get_ber_identifier(parameter_tvb, 0, &ber_class, &pc, &tag);
1325
1326
  /*if ((ldap_info->auth_mech != NULL) && (strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) && (ber_class==BER_CLASS_CON)) {*/
1327
0
  if ((ldap_info->auth_mech != NULL) && (ber_class==BER_CLASS_CON)) {
1328
    /*
1329
     * This is a GSS-API token ancapsulated within GSS-SPNEGO.
1330
     * We need to check the first byte to check whether the blob
1331
     * contains SPNEGO or GSSAPI.
1332
     * All SPNEGO PDUs are of class CONSTRUCTED while
1333
     * GSS PDUs are class APPLICATION
1334
     */
1335
0
    if (parameter_tvb && (tvb_reported_length(parameter_tvb) > 0))
1336
0
      call_dissector(spnego_handle, parameter_tvb, actx->pinfo, tree);
1337
0
  }
1338
  /*if ((ldap_info->auth_mech != NULL) && ((strcmp(ldap_info->auth_mech, "GSSAPI") == 0) || (ber_class==BER_CLASS_APP))) {*/
1339
0
  if ((ldap_info->auth_mech != NULL) && (ber_class==BER_CLASS_APP)) {
1340
    /*
1341
     * This is a raw GSS-API token.
1342
     */
1343
0
    if (parameter_tvb && (tvb_reported_length(parameter_tvb) > 0)) {
1344
0
      call_dissector(gssapi_handle, parameter_tvb, actx->pinfo, tree);
1345
0
    }
1346
0
  }
1347
  /* Restore private data */
1348
0
  actx->private_data = ldap_info;
1349
1350
1351
1352
0
  return offset;
1353
0
}
1354
1355
1356
static const ber_sequence_t SaslCredentials_sequence[] = {
1357
  { &hf_ldap_mechanism      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_Mechanism },
1358
  { &hf_ldap_credentials    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_Credentials },
1359
  { NULL, 0, 0, 0, NULL }
1360
};
1361
1362
static unsigned
1363
0
dissect_ldap_SaslCredentials(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1364
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1365
0
                                   SaslCredentials_sequence, hf_index, ett_ldap_SaslCredentials);
1366
1367
0
  return offset;
1368
0
}
1369
1370
1371
1372
static unsigned
1373
0
dissect_ldap_T_ntlmsspNegotiate(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1374
  /* make sure the protocol op comes first */
1375
0
  ldap_do_protocolop(actx->pinfo);
1376
1377
0
  call_dissector(ntlmssp_handle, tvb, actx->pinfo, tree);
1378
0
  offset+=tvb_reported_length_remaining(tvb, offset);
1379
1380
1381
0
  return offset;
1382
0
}
1383
1384
1385
1386
static unsigned
1387
0
dissect_ldap_T_ntlmsspAuth(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1388
  /* make sure the protocol op comes first */
1389
0
  ldap_do_protocolop(actx->pinfo);
1390
1391
0
  call_dissector(ntlmssp_handle, tvb, actx->pinfo, tree);
1392
0
  offset+=tvb_reported_length_remaining(tvb, offset);
1393
1394
1395
0
  return offset;
1396
0
}
1397
1398
1399
static const value_string ldap_AuthenticationChoice_vals[] = {
1400
  {   0, "simple" },
1401
  {   3, "sasl" },
1402
  {  10, "ntlmsspNegotiate" },
1403
  {  11, "ntlmsspAuth" },
1404
  { 0, NULL }
1405
};
1406
1407
static const ber_choice_t AuthenticationChoice_choice[] = {
1408
  {   0, &hf_ldap_simple         , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_Simple },
1409
  {   3, &hf_ldap_sasl           , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_SaslCredentials },
1410
  {  10, &hf_ldap_ntlmsspNegotiate, BER_CLASS_CON, 10, BER_FLAGS_IMPLTAG, dissect_ldap_T_ntlmsspNegotiate },
1411
  {  11, &hf_ldap_ntlmsspAuth    , BER_CLASS_CON, 11, BER_FLAGS_IMPLTAG, dissect_ldap_T_ntlmsspAuth },
1412
  { 0, NULL, 0, 0, 0, NULL }
1413
};
1414
1415
static unsigned
1416
0
dissect_ldap_AuthenticationChoice(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1417
0
  int branch = -1;
1418
0
  int auth = -1;
1419
0
  const char *valstr;
1420
1421
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
1422
0
                                 AuthenticationChoice_choice, hf_index, ett_ldap_AuthenticationChoice,
1423
0
                                 &branch);
1424
1425
1426
0
  ldap_do_protocolop(actx->pinfo);
1427
1428
0
  if((branch > -1) && (branch < (int)array_length(AuthenticationChoice_choice)))
1429
0
    auth = AuthenticationChoice_choice[branch].value;
1430
1431
0
  valstr = val_to_str(actx->pinfo->pool, auth, ldap_AuthenticationChoice_vals, "Unknown auth(%u)");
1432
1433
  /* If auth is NTLM (10 or 11) don't add to column as the NTLM dissection will do this */
1434
0
  if ((auth !=  10) && (auth != 11))
1435
0
    col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
1436
1437
0
  if(ldm_tree)
1438
0
    proto_item_append_text(ldm_tree, " %s", valstr);
1439
1440
1441
1442
0
  return offset;
1443
0
}
1444
1445
1446
static const ber_sequence_t BindRequest_U_sequence[] = {
1447
  { &hf_ldap_version        , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER_1_127 },
1448
  { &hf_ldap_name           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
1449
  { &hf_ldap_authentication , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_AuthenticationChoice },
1450
  { NULL, 0, 0, 0, NULL }
1451
};
1452
1453
static unsigned
1454
2
dissect_ldap_BindRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1455
2
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1456
2
                                   BindRequest_U_sequence, hf_index, ett_ldap_BindRequest_U);
1457
1458
2
  return offset;
1459
2
}
1460
1461
1462
1463
static unsigned
1464
2
dissect_ldap_BindRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1465
2
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1466
2
                                      hf_index, BER_CLASS_APP, 0, true, dissect_ldap_BindRequest_U);
1467
1468
2
  return offset;
1469
2
}
1470
1471
1472
static const value_string ldap_BindResponse_resultCode_vals[] = {
1473
  {   0, "success" },
1474
  {   1, "operationsError" },
1475
  {   2, "protocolError" },
1476
  {   3, "timeLimitExceeded" },
1477
  {   4, "sizeLimitExceeded" },
1478
  {   5, "compareFalse" },
1479
  {   6, "compareTrue" },
1480
  {   7, "authMethodNotSupported" },
1481
  {   8, "strongAuthRequired" },
1482
  {  10, "referral" },
1483
  {  11, "adminLimitExceeded" },
1484
  {  12, "unavailableCriticalExtension" },
1485
  {  13, "confidentialityRequired" },
1486
  {  14, "saslBindInProgress" },
1487
  {  16, "noSuchAttribute" },
1488
  {  17, "undefinedAttributeType" },
1489
  {  18, "inappropriateMatching" },
1490
  {  19, "constraintViolation" },
1491
  {  20, "attributeOrValueExists" },
1492
  {  21, "invalidAttributeSyntax" },
1493
  {  32, "noSuchObject" },
1494
  {  33, "aliasProblem" },
1495
  {  34, "invalidDNSyntax" },
1496
  {  36, "aliasDereferencingProblem" },
1497
  {  48, "inappropriateAuthentication" },
1498
  {  49, "invalidCredentials" },
1499
  {  50, "insufficientAccessRights" },
1500
  {  51, "busy" },
1501
  {  52, "unavailable" },
1502
  {  53, "unwillingToPerform" },
1503
  {  54, "loopDetect" },
1504
  {  64, "namingViolation" },
1505
  {  65, "objectClassViolation" },
1506
  {  66, "notAllowedOnNonLeaf" },
1507
  {  67, "notAllowedOnRDN" },
1508
  {  68, "entryAlreadyExists" },
1509
  {  69, "objectClassModsProhibited" },
1510
  {  71, "affectsMultipleDSAs" },
1511
  {  80, "other" },
1512
  { 118, "canceled" },
1513
  { 119, "noSuchOperation" },
1514
  { 120, "tooLate" },
1515
  { 121, "cannotCancel" },
1516
  { 0, NULL }
1517
};
1518
1519
1520
static unsigned
1521
0
dissect_ldap_BindResponse_resultCode(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1522
1523
0
  const char *valstr;
1524
0
  unsigned result;
1525
1526
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1527
0
                                  &result);
1528
1529
1530
0
  ldap_do_protocolop(actx->pinfo);
1531
1532
0
  valstr = val_to_str(actx->pinfo->pool, result, ldap_BindResponse_resultCode_vals, "Unknown result(%u)");
1533
1534
0
  col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
1535
1536
0
  if(ldm_tree)
1537
0
    proto_item_append_text(ldm_tree, " %s", valstr);
1538
1539
1540
0
  return offset;
1541
0
}
1542
1543
1544
1545
static unsigned
1546
0
dissect_ldap_T_bindResponse_matchedDN(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1547
0
  tvbuff_t *new_tvb=NULL;
1548
1549
0
  offset = dissect_ber_octet_string(false, actx, tree, tvb, offset, hf_ldap_matchedDN, &new_tvb);
1550
1551
0
  if(  new_tvb
1552
0
  &&  (tvb_reported_length(new_tvb)>=7)
1553
0
  &&  (!tvb_memeql(new_tvb, 0, (const uint8_t*)"NTLMSSP", 7))){
1554
1555
    /* make sure the protocol op comes first */
1556
0
    ldap_do_protocolop(actx->pinfo);
1557
1558
0
    call_dissector(ntlmssp_handle, new_tvb, actx->pinfo, tree);
1559
0
  }
1560
1561
1562
0
  return offset;
1563
0
}
1564
1565
1566
1567
static unsigned
1568
3
dissect_ldap_ErrorMessage(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1569
3
  offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
1570
1571
3
  return offset;
1572
3
}
1573
1574
1575
1576
static unsigned
1577
7
dissect_ldap_LDAPURL(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1578
7
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1579
7
                                       NULL);
1580
1581
7
  proto_item_set_url(actx->created_item);
1582
1583
7
  return offset;
1584
7
}
1585
1586
1587
static const ber_sequence_t Referral_sequence_of[1] = {
1588
  { &hf_ldap_Referral_item  , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPURL },
1589
};
1590
1591
static unsigned
1592
0
dissect_ldap_Referral(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1593
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1594
0
                                      Referral_sequence_of, hf_index, ett_ldap_Referral);
1595
1596
0
  return offset;
1597
0
}
1598
1599
1600
1601
static unsigned
1602
0
dissect_ldap_ServerSaslCreds(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1603
1604
0
tvbuff_t *parameter_tvb = NULL;
1605
0
ldap_conv_info_t *ldap_info;
1606
1607
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1608
0
                                       &parameter_tvb);
1609
1610
0
  if (!parameter_tvb)
1611
0
    return offset;
1612
0
  ldap_info = (ldap_conv_info_t *)actx->private_data;
1613
0
  switch (ldap_info->auth_type) {
1614
1615
    /* For Kerberos V4, dissect it as a ticket. */
1616
    /* XXX - what about LDAP_AUTH_SIMPLE? */
1617
1618
0
  case LDAP_AUTH_SASL:
1619
    /*
1620
     * All frames after this are assumed to use a security layer.
1621
     *
1622
     * XXX - won't work if there's another reply, with the security
1623
     * layer, starting in the same TCP segment that ends this
1624
     * reply, but as LDAP is a request/response protocol, and
1625
     * as the client probably can't start using authentication until
1626
     * it gets the bind reply and the server won't send a reply until
1627
     * it gets a request, that probably won't happen.
1628
     *
1629
     * XXX - that assumption is invalid; it's not clear where the
1630
     * hell you find out whether there's any security layer.  In
1631
     * one capture, we have two GSS-SPNEGO negotiations, both of
1632
     * which select MS KRB5, and the only differences in the tokens
1633
     * is in the RC4-HMAC ciphertext.  The various
1634
     * draft-ietf--cat-sasl-gssapi-NN.txt drafts seem to imply
1635
     * that the RFC 2222 spoo with the bitmask and maximum
1636
     * output message size stuff is done - but where does that
1637
     * stuff show up?  Is it in the ciphertext, which means it's
1638
     * presumably encrypted?
1639
     *
1640
     * Grrr.  We have to do a gross heuristic, checking whether the
1641
     * putative LDAP message begins with 0x00 or not, making the
1642
     * assumption that we won't have more than 2^24 bytes of
1643
     * encapsulated stuff.
1644
     */
1645
0
    ldap_info->first_auth_frame = actx->pinfo->num + 1;
1646
0
    if (ldap_info->auth_mech != NULL &&
1647
0
      strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) {
1648
      /* It could be the second leg of GSS-SPNEGO wrapping NTLMSSP
1649
       * which might not be wrapped in GSS-SPNEGO but be a raw
1650
       * NTLMSSP blob
1651
       */
1652
0
      if ( (tvb_reported_length(parameter_tvb)>=7)
1653
0
        &&   (!tvb_memeql(parameter_tvb, 0, (const uint8_t*)"NTLMSSP", 7))){
1654
0
        call_dissector(ntlmssp_handle, parameter_tvb, actx->pinfo, tree);
1655
0
        break;
1656
0
      }
1657
      /*
1658
       * This is a GSS-API token.
1659
       */
1660
0
      if(parameter_tvb && (tvb_reported_length(parameter_tvb) > 0))
1661
0
        call_dissector(spnego_handle, parameter_tvb, actx->pinfo, tree);
1662
0
    } else if (ldap_info->auth_mech != NULL &&
1663
0
      strcmp(ldap_info->auth_mech, "GSSAPI") == 0) {
1664
      /*
1665
       * This is a GSS-API token.
1666
       */
1667
0
      if(parameter_tvb && (tvb_reported_length(parameter_tvb) > 0))
1668
0
          call_dissector(gssapi_handle, parameter_tvb, actx->pinfo, tree);
1669
0
    }
1670
0
  break;
1671
0
  }
1672
0
  actx->private_data = ldap_info;
1673
1674
1675
0
  return offset;
1676
0
}
1677
1678
1679
static const ber_sequence_t BindResponse_U_sequence[] = {
1680
  { &hf_ldap_bindResponse_resultCode, BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_BindResponse_resultCode },
1681
  { &hf_ldap_bindResponse_matchedDN, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_T_bindResponse_matchedDN },
1682
  { &hf_ldap_errorMessage   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ErrorMessage },
1683
  { &hf_ldap_referral       , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Referral },
1684
  { &hf_ldap_serverSaslCreds, BER_CLASS_CON, 7, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_ServerSaslCreds },
1685
  { NULL, 0, 0, 0, NULL }
1686
};
1687
1688
static unsigned
1689
5
dissect_ldap_BindResponse_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1690
5
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1691
5
                                   BindResponse_U_sequence, hf_index, ett_ldap_BindResponse_U);
1692
1693
5
  return offset;
1694
5
}
1695
1696
1697
1698
static unsigned
1699
5
dissect_ldap_BindResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1700
5
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1701
5
                                      hf_index, BER_CLASS_APP, 1, true, dissect_ldap_BindResponse_U);
1702
1703
5
  return offset;
1704
5
}
1705
1706
1707
1708
static unsigned
1709
3
dissect_ldap_NULL(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1710
3
  offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
1711
1712
3
  return offset;
1713
3
}
1714
1715
1716
1717
static unsigned
1718
3
dissect_ldap_UnbindRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1719
1720
3
  implicit_tag = true; /* correct problem with asn2wrs */
1721
1722
3
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1723
3
                                      hf_index, BER_CLASS_APP, 2, true, dissect_ldap_NULL);
1724
1725
1726
3
  ldap_do_protocolop(actx->pinfo);
1727
1728
1729
1730
1731
1732
1733
3
  return offset;
1734
3
}
1735
1736
1737
static const value_string ldap_T_scope_vals[] = {
1738
  {   0, "baseObject" },
1739
  {   1, "singleLevel" },
1740
  {   2, "wholeSubtree" },
1741
  { 0, NULL }
1742
};
1743
1744
1745
static unsigned
1746
1
dissect_ldap_T_scope(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1747
1748
1
  uint32_t scope = 0xffff;
1749
1
  const char *valstr;
1750
1751
1
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1752
1
                                  &scope);
1753
1754
1755
1
  ldap_do_protocolop(actx->pinfo);
1756
1757
1
  valstr = val_to_str(actx->pinfo->pool, scope, ldap_T_scope_vals, "Unknown scope(%u)");
1758
1759
1
  col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
1760
1761
1
  if(ldm_tree)
1762
0
    proto_item_append_text(ldm_tree, " %s", valstr);
1763
1764
1765
1
  return offset;
1766
1
}
1767
1768
1769
static const value_string ldap_T_derefAliases_vals[] = {
1770
  {   0, "neverDerefAliases" },
1771
  {   1, "derefInSearching" },
1772
  {   2, "derefFindingBaseObj" },
1773
  {   3, "derefAlways" },
1774
  { 0, NULL }
1775
};
1776
1777
1778
static unsigned
1779
0
dissect_ldap_T_derefAliases(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1780
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1781
0
                                  NULL);
1782
1783
0
  return offset;
1784
0
}
1785
1786
1787
1788
static unsigned
1789
5
dissect_ldap_INTEGER_0_maxInt(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1790
5
  offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset,
1791
5
                                                            0U, maxInt, hf_index, NULL);
1792
1793
5
  return offset;
1794
5
}
1795
1796
1797
1798
static unsigned
1799
1
dissect_ldap_BOOLEAN(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1800
1
  offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
1801
1802
1
  return offset;
1803
1
}
1804
1805
1806
1807
static unsigned
1808
0
dissect_ldap_T_and_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1809
0
  offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
1810
1811
0
  if(and_filter_string){
1812
0
    and_filter_string=wmem_strdup_printf(actx->pinfo->pool, "(&%s%s)",and_filter_string,Filter_string);
1813
0
  } else {
1814
0
    and_filter_string=wmem_strdup_printf(actx->pinfo->pool, "(&%s)",Filter_string);
1815
0
  }
1816
1817
0
  return offset;
1818
0
}
1819
1820
1821
static const ber_sequence_t T_and_set_of[1] = {
1822
  { &hf_ldap_and_item       , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_and_item },
1823
};
1824
1825
static unsigned
1826
0
dissect_ldap_T_and(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1827
0
  proto_tree *tr=NULL;
1828
0
  proto_item *it=NULL;
1829
0
  const char *old_and_filter_string=and_filter_string;
1830
1831
0
  and_filter_string=NULL;
1832
1833
0
  tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_T_and, &it, "and: ");
1834
0
  tree = tr;
1835
1836
0
  offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
1837
0
                                 T_and_set_of, hf_index, ett_ldap_T_and);
1838
1839
1840
0
  if(and_filter_string) {
1841
0
    proto_item_append_text(it, "%s", and_filter_string);
1842
0
    Filter_string=wmem_strdup(actx->pinfo->pool, and_filter_string);
1843
0
  }
1844
0
  and_filter_string=old_and_filter_string;
1845
1846
1847
0
  return offset;
1848
0
}
1849
1850
1851
1852
static unsigned
1853
1
dissect_ldap_T_or_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1854
1
  offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
1855
1856
1
  if(or_filter_string){
1857
0
    or_filter_string=wmem_strdup_printf(actx->pinfo->pool, "(|%s%s)",or_filter_string,Filter_string);
1858
1
  } else {
1859
1
    or_filter_string=wmem_strdup_printf(actx->pinfo->pool, "(|%s)",Filter_string);
1860
1
  }
1861
1862
1863
1
  return offset;
1864
1
}
1865
1866
1867
static const ber_sequence_t T_or_set_of[1] = {
1868
  { &hf_ldap_or_item        , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_or_item },
1869
};
1870
1871
static unsigned
1872
1
dissect_ldap_T_or(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1873
1
  proto_tree *tr;
1874
1
  proto_item *it;
1875
1
  const char *old_or_filter_string=or_filter_string;
1876
1877
1
  or_filter_string=NULL;
1878
1
  tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_T_or, &it, "or: ");
1879
1
  tree = tr;
1880
1881
1
  offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
1882
1
                                 T_or_set_of, hf_index, ett_ldap_T_or);
1883
1884
1
  if(or_filter_string) {
1885
1
    proto_item_append_text(it, "%s", or_filter_string);
1886
1
    Filter_string=wmem_strdup(actx->pinfo->pool, or_filter_string);
1887
1
  }
1888
1
  or_filter_string=old_or_filter_string;
1889
1890
1891
1
  return offset;
1892
1
}
1893
1894
1895
1896
static unsigned
1897
7
dissect_ldap_T_not(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1898
7
  offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
1899
1900
7
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(!%s)",string_or_null(Filter_string));
1901
1902
7
  return offset;
1903
7
}
1904
1905
1906
1907
static unsigned
1908
0
dissect_ldap_AttributeDescription(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1909
0
  offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
1910
1911
0
  return offset;
1912
0
}
1913
1914
1915
1916
static const ber_sequence_t AttributeValueAssertion_sequence[] = {
1917
  { &hf_ldap_attributeDesc  , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
1918
  { &hf_ldap_assertionValue , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AssertionValue },
1919
  { NULL, 0, 0, 0, NULL }
1920
};
1921
1922
static unsigned
1923
1
dissect_ldap_AttributeValueAssertion(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1924
1
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1925
1
                                   AttributeValueAssertion_sequence, hf_index, ett_ldap_AttributeValueAssertion);
1926
1927
1
  return offset;
1928
1
}
1929
1930
1931
1932
static unsigned
1933
0
dissect_ldap_T_equalityMatch(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1934
0
  offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
1935
1936
0
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s=%s)",
1937
0
                                   string_or_null(attributedesc_string),
1938
0
                                   string_or_null(ldapvalue_string));
1939
1940
1941
0
  return offset;
1942
0
}
1943
1944
1945
static const value_string ldap_T_substringFilter_substrings_item_vals[] = {
1946
  {   0, "initial" },
1947
  {   1, "any" },
1948
  {   2, "final" },
1949
  { 0, NULL }
1950
};
1951
1952
static const ber_choice_t T_substringFilter_substrings_item_choice[] = {
1953
  {   0, &hf_ldap_initial        , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPString },
1954
  {   1, &hf_ldap_any            , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPString },
1955
  {   2, &hf_ldap_final          , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPString },
1956
  { 0, NULL, 0, 0, 0, NULL }
1957
};
1958
1959
static unsigned
1960
0
dissect_ldap_T_substringFilter_substrings_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1961
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
1962
0
                                 T_substringFilter_substrings_item_choice, hf_index, ett_ldap_T_substringFilter_substrings_item,
1963
0
                                 NULL);
1964
1965
0
  if (substring_item_final) {
1966
0
    substring_value=wmem_strdup_printf(actx->pinfo->pool, "%s%s",
1967
0
                                      (substring_value?substring_value:"*"),
1968
0
                                       substring_item_final);
1969
0
  } else if (substring_item_any) {
1970
0
    substring_value=wmem_strdup_printf(actx->pinfo->pool, "%s%s*",
1971
0
                                      (substring_value?substring_value:"*"),
1972
0
                                       substring_item_any);
1973
0
  } else if (substring_item_init) {
1974
0
    substring_value=wmem_strdup_printf(actx->pinfo->pool, "%s*",
1975
0
                                       substring_item_init);
1976
0
  }
1977
1978
0
  return offset;
1979
0
}
1980
1981
1982
static const ber_sequence_t T_substringFilter_substrings_sequence_of[1] = {
1983
  { &hf_ldap_substringFilter_substrings_item, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_substringFilter_substrings_item },
1984
};
1985
1986
static unsigned
1987
0
dissect_ldap_T_substringFilter_substrings(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1988
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1989
0
                                      T_substringFilter_substrings_sequence_of, hf_index, ett_ldap_T_substringFilter_substrings);
1990
1991
0
  return offset;
1992
0
}
1993
1994
1995
static const ber_sequence_t SubstringFilter_sequence[] = {
1996
  { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
1997
  { &hf_ldap_substringFilter_substrings, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_T_substringFilter_substrings },
1998
  { NULL, 0, 0, 0, NULL }
1999
};
2000
2001
static unsigned
2002
0
dissect_ldap_SubstringFilter(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2003
0
  proto_tree *tr;
2004
0
  proto_item *it;
2005
0
  const char *old_substring_value=substring_value;
2006
2007
0
  attr_type=NULL;
2008
0
  substring_value=NULL;
2009
0
  substring_item_init=NULL;
2010
0
  substring_item_any=NULL;
2011
0
  substring_item_final=NULL;
2012
2013
0
  tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_SubstringFilter, &it, "substring: ");
2014
0
  tree = tr;
2015
2016
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2017
0
                                   SubstringFilter_sequence, hf_index, ett_ldap_SubstringFilter);
2018
2019
0
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s=%s)",
2020
0
                                   string_or_null(attr_type),
2021
0
                                   string_or_null(substring_value));
2022
0
  proto_item_append_text(it, "%s", Filter_string);
2023
0
  substring_value=old_substring_value;
2024
2025
2026
0
  return offset;
2027
0
}
2028
2029
2030
2031
static unsigned
2032
0
dissect_ldap_T_greaterOrEqual(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2033
0
  offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2034
2035
0
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s>=%s)",
2036
0
                                   string_or_null(attributedesc_string),
2037
0
                                   string_or_null(ldapvalue_string));
2038
2039
2040
0
  return offset;
2041
0
}
2042
2043
2044
2045
static unsigned
2046
1
dissect_ldap_T_lessOrEqual(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2047
1
  offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2048
2049
1
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s<=%s)",
2050
1
                                   string_or_null(attributedesc_string),
2051
1
                                   string_or_null(ldapvalue_string));
2052
2053
2054
1
  return offset;
2055
1
}
2056
2057
2058
2059
static unsigned
2060
0
dissect_ldap_T_present(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2061
0
  offset = dissect_ldap_AttributeDescription(implicit_tag, tvb, offset, actx, tree, hf_index);
2062
2063
0
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s=*)",string_or_null(Filter_string));
2064
2065
0
  return offset;
2066
0
}
2067
2068
2069
2070
static unsigned
2071
0
dissect_ldap_T_approxMatch(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2072
0
  offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2073
2074
0
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s~=%s)",
2075
0
                                   string_or_null(attributedesc_string),
2076
0
                                   string_or_null(ldapvalue_string));
2077
2078
0
  return offset;
2079
0
}
2080
2081
2082
2083
static unsigned
2084
0
dissect_ldap_MatchingRuleId(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2085
0
  offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
2086
2087
0
  return offset;
2088
0
}
2089
2090
2091
2092
static unsigned
2093
0
dissect_ldap_T_dnAttributes(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2094
0
  bool val;
2095
2096
0
  offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &val);
2097
2098
2099
0
  matching_rule_dnattr = val;
2100
2101
2102
2103
0
  return offset;
2104
0
}
2105
2106
2107
static const ber_sequence_t MatchingRuleAssertion_sequence[] = {
2108
  { &hf_ldap_matchingRule   , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_MatchingRuleId },
2109
  { &hf_ldap_type           , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_AttributeDescription },
2110
  { &hf_ldap_matchValue     , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_AssertionValue },
2111
  { &hf_ldap_dnAttributes   , BER_CLASS_CON, 4, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_dnAttributes },
2112
  { NULL, 0, 0, 0, NULL }
2113
};
2114
2115
static unsigned
2116
0
dissect_ldap_MatchingRuleAssertion(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2117
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2118
0
                                   MatchingRuleAssertion_sequence, hf_index, ett_ldap_MatchingRuleAssertion);
2119
2120
0
  return offset;
2121
0
}
2122
2123
2124
2125
static unsigned
2126
0
dissect_ldap_T_extensibleMatch(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2127
0
  attr_type=NULL;
2128
0
  matching_rule_string=NULL;
2129
0
  ldapvalue_string=NULL;
2130
0
  matching_rule_dnattr=false;
2131
2132
0
  offset = dissect_ldap_MatchingRuleAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2133
2134
0
  Filter_string=wmem_strdup_printf(actx->pinfo->pool, "(%s:%s%s%s=%s)",
2135
0
                                  (attr_type?attr_type:""),
2136
0
                                  (matching_rule_dnattr?"dn:":""),
2137
0
                                  (matching_rule_string?matching_rule_string:""),
2138
0
                                  (matching_rule_string?":":""),
2139
0
                                   string_or_null(ldapvalue_string));
2140
2141
0
  return offset;
2142
0
}
2143
2144
2145
static const value_string ldap_Filter_vals[] = {
2146
  {   0, "and" },
2147
  {   1, "or" },
2148
  {   2, "not" },
2149
  {   3, "equalityMatch" },
2150
  {   4, "substrings" },
2151
  {   5, "greaterOrEqual" },
2152
  {   6, "lessOrEqual" },
2153
  {   7, "present" },
2154
  {   8, "approxMatch" },
2155
  {   9, "extensibleMatch" },
2156
  { 0, NULL }
2157
};
2158
2159
static const ber_choice_t Filter_choice[] = {
2160
  {   0, &hf_ldap_and            , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_T_and },
2161
  {   1, &hf_ldap_or             , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_T_or },
2162
  {   2, &hf_ldap_not            , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ldap_T_not },
2163
  {   3, &hf_ldap_equalityMatch  , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_T_equalityMatch },
2164
  {   4, &hf_ldap_substrings     , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_ldap_SubstringFilter },
2165
  {   5, &hf_ldap_greaterOrEqual , BER_CLASS_CON, 5, BER_FLAGS_IMPLTAG, dissect_ldap_T_greaterOrEqual },
2166
  {   6, &hf_ldap_lessOrEqual    , BER_CLASS_CON, 6, BER_FLAGS_IMPLTAG, dissect_ldap_T_lessOrEqual },
2167
  {   7, &hf_ldap_present        , BER_CLASS_CON, 7, BER_FLAGS_IMPLTAG, dissect_ldap_T_present },
2168
  {   8, &hf_ldap_approxMatch    , BER_CLASS_CON, 8, BER_FLAGS_IMPLTAG, dissect_ldap_T_approxMatch },
2169
  {   9, &hf_ldap_extensibleMatch, BER_CLASS_CON, 9, BER_FLAGS_IMPLTAG, dissect_ldap_T_extensibleMatch },
2170
  { 0, NULL, 0, 0, 0, NULL }
2171
};
2172
2173
static unsigned
2174
14
dissect_ldap_Filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2175
  // Filter -> Filter/and -> Filter/and/_item -> Filter
2176
14
  increment_dissection_depth_by_n(actx->pinfo, 3);
2177
14
  proto_tree *tr;
2178
14
  proto_item *it;
2179
14
  attributedesc_string=NULL;
2180
2181
14
  if (Filter_length++ > MAX_FILTER_LEN) {
2182
0
    expert_add_info_format(actx->pinfo, tree, &ei_ldap_exceeded_filter_length, "Filter length exceeds %u. Giving up.", MAX_FILTER_LEN);
2183
0
    THROW(ReportedBoundsError);
2184
0
  }
2185
2186
14
  if (Filter_elements++ > MAX_FILTER_ELEMENTS) {
2187
0
    expert_add_info_format(actx->pinfo, tree, &ei_ldap_too_many_filter_elements, "Found more than %u filter elements. Giving up.", MAX_FILTER_ELEMENTS);
2188
0
    THROW(ReportedBoundsError);
2189
0
  }
2190
2191
14
  tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_Filter, &it, "Filter: ");
2192
14
  tree = tr;
2193
2194
14
  offset = dissect_ber_choice(actx, tree, tvb, offset,
2195
14
                                 Filter_choice, hf_index, ett_ldap_Filter,
2196
14
                                 NULL);
2197
2198
14
  if(Filter_string)
2199
2
    proto_item_append_text(it, "%s", string_or_null(Filter_string));
2200
2201
2202
14
  decrement_dissection_depth_by_n(actx->pinfo, 3);
2203
14
  return offset;
2204
14
}
2205
2206
2207
2208
static unsigned
2209
6
dissect_ldap_T_filter(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2210
6
  Filter_string=NULL;
2211
6
  Filter_elements = 0;
2212
6
  Filter_length = 0;
2213
2214
6
  offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
2215
2216
6
  Filter_string=NULL;
2217
6
  and_filter_string=NULL;
2218
6
  Filter_elements = 0;
2219
6
  Filter_length = 0;
2220
2221
6
  return offset;
2222
6
}
2223
2224
2225
static const ber_sequence_t AttributeDescriptionList_sequence_of[1] = {
2226
  { &hf_ldap_AttributeDescriptionList_item, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2227
};
2228
2229
static unsigned
2230
0
dissect_ldap_AttributeDescriptionList(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2231
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2232
0
                                      AttributeDescriptionList_sequence_of, hf_index, ett_ldap_AttributeDescriptionList);
2233
2234
0
  return offset;
2235
0
}
2236
2237
2238
static const ber_sequence_t SearchRequest_U_sequence[] = {
2239
  { &hf_ldap_baseObject     , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2240
  { &hf_ldap_scope          , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_scope },
2241
  { &hf_ldap_derefAliases   , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_derefAliases },
2242
  { &hf_ldap_sizeLimit      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER_0_maxInt },
2243
  { &hf_ldap_timeLimit      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER_0_maxInt },
2244
  { &hf_ldap_typesOnly      , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
2245
  { &hf_ldap_filter         , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_filter },
2246
  { &hf_ldap_searchRequest_attributes, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescriptionList },
2247
  { NULL, 0, 0, 0, NULL }
2248
};
2249
2250
static unsigned
2251
16
dissect_ldap_SearchRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2252
16
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2253
16
                                   SearchRequest_U_sequence, hf_index, ett_ldap_SearchRequest_U);
2254
2255
16
  return offset;
2256
16
}
2257
2258
2259
2260
static unsigned
2261
16
dissect_ldap_SearchRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2262
16
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2263
16
                                      hf_index, BER_CLASS_APP, 3, true, dissect_ldap_SearchRequest_U);
2264
2265
16
  return offset;
2266
16
}
2267
2268
2269
2270
static unsigned
2271
0
dissect_ldap_AttributeValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2272
2273
0
  tvbuff_t  *next_tvb = NULL;
2274
0
  char *string;
2275
0
  int old_offset = offset;
2276
0
  int *hf_id;
2277
2278
  /* attr_type, should be set before calling this function */
2279
2280
  /* extract the value of the octetstring */
2281
0
  offset = dissect_ber_octet_string(false, actx, tree, tvb, offset, -1, &next_tvb);
2282
2283
  /* first check if we have a custom attribute type configured */
2284
0
  if ((hf_id = get_hf_for_header (attr_type)) != NULL)
2285
0
    proto_tree_add_item (tree, *hf_id, next_tvb, 0, tvb_reported_length_remaining(next_tvb, 0), ENC_UTF_8|ENC_NA);
2286
2287
  /* if we have an attribute type that isn't binary see if there is a better dissector */
2288
0
  else if(!attr_type || !next_tvb || !dissector_try_string_with_data(ldap_name_dissector_table, attr_type, next_tvb, actx->pinfo, tree, false, NULL)) {
2289
0
    offset = old_offset;
2290
2291
    /* do the default thing */
2292
0
    offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2293
0
                                       NULL);
2294
2295
2296
0
    if(tvb_ascii_isprint(next_tvb, 0, tvb_reported_length(next_tvb))) {
2297
0
      string = (char*)tvb_get_string_enc(actx->pinfo->pool, next_tvb, 0, tvb_reported_length_remaining(next_tvb, 0), ENC_UTF_8|ENC_NA);
2298
0
      proto_item_set_text(actx->created_item, "AttributeValue: %s", string);
2299
0
    }
2300
0
  }
2301
2302
2303
0
  return offset;
2304
0
}
2305
2306
2307
static const ber_sequence_t SET_OF_AttributeValue_set_of[1] = {
2308
  { &hf_ldap_vals_item      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeValue },
2309
};
2310
2311
static unsigned
2312
0
dissect_ldap_SET_OF_AttributeValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2313
0
  offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
2314
0
                                 SET_OF_AttributeValue_set_of, hf_index, ett_ldap_SET_OF_AttributeValue);
2315
2316
0
  return offset;
2317
0
}
2318
2319
2320
static const ber_sequence_t PartialAttributeList_item_sequence[] = {
2321
  { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2322
  { &hf_ldap_vals           , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_AttributeValue },
2323
  { NULL, 0, 0, 0, NULL }
2324
};
2325
2326
static unsigned
2327
0
dissect_ldap_PartialAttributeList_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2328
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2329
0
                                   PartialAttributeList_item_sequence, hf_index, ett_ldap_PartialAttributeList_item);
2330
2331
0
  return offset;
2332
0
}
2333
2334
2335
static const ber_sequence_t PartialAttributeList_sequence_of[1] = {
2336
  { &hf_ldap_PartialAttributeList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_PartialAttributeList_item },
2337
};
2338
2339
static unsigned
2340
1
dissect_ldap_PartialAttributeList(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2341
1
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2342
1
                                      PartialAttributeList_sequence_of, hf_index, ett_ldap_PartialAttributeList);
2343
2344
1
  return offset;
2345
1
}
2346
2347
2348
static const ber_sequence_t SearchResultEntry_U_sequence[] = {
2349
  { &hf_ldap_objectName     , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2350
  { &hf_ldap_searchResultEntry_attributes, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_PartialAttributeList },
2351
  { NULL, 0, 0, 0, NULL }
2352
};
2353
2354
static unsigned
2355
8
dissect_ldap_SearchResultEntry_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2356
8
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2357
8
                                   SearchResultEntry_U_sequence, hf_index, ett_ldap_SearchResultEntry_U);
2358
2359
8
  return offset;
2360
8
}
2361
2362
2363
2364
static unsigned
2365
8
dissect_ldap_SearchResultEntry(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2366
8
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2367
8
                                      hf_index, BER_CLASS_APP, 4, true, dissect_ldap_SearchResultEntry_U);
2368
2369
8
  return offset;
2370
8
}
2371
2372
2373
static const value_string ldap_T_resultCode_vals[] = {
2374
  {   0, "success" },
2375
  {   1, "operationsError" },
2376
  {   2, "protocolError" },
2377
  {   3, "timeLimitExceeded" },
2378
  {   4, "sizeLimitExceeded" },
2379
  {   5, "compareFalse" },
2380
  {   6, "compareTrue" },
2381
  {   7, "authMethodNotSupported" },
2382
  {   8, "strongAuthRequired" },
2383
  {  10, "referral" },
2384
  {  11, "adminLimitExceeded" },
2385
  {  12, "unavailableCriticalExtension" },
2386
  {  13, "confidentialityRequired" },
2387
  {  14, "saslBindInProgress" },
2388
  {  16, "noSuchAttribute" },
2389
  {  17, "undefinedAttributeType" },
2390
  {  18, "inappropriateMatching" },
2391
  {  19, "constraintViolation" },
2392
  {  20, "attributeOrValueExists" },
2393
  {  21, "invalidAttributeSyntax" },
2394
  {  32, "noSuchObject" },
2395
  {  33, "aliasProblem" },
2396
  {  34, "invalidDNSyntax" },
2397
  {  36, "aliasDereferencingProblem" },
2398
  {  48, "inappropriateAuthentication" },
2399
  {  49, "invalidCredentials" },
2400
  {  50, "insufficientAccessRights" },
2401
  {  51, "busy" },
2402
  {  52, "unavailable" },
2403
  {  53, "unwillingToPerform" },
2404
  {  54, "loopDetect" },
2405
  {  64, "namingViolation" },
2406
  {  65, "objectClassViolation" },
2407
  {  66, "notAllowedOnNonLeaf" },
2408
  {  67, "notAllowedOnRDN" },
2409
  {  68, "entryAlreadyExists" },
2410
  {  69, "objectClassModsProhibited" },
2411
  {  71, "affectsMultipleDSAs" },
2412
  {  80, "other" },
2413
  { 118, "canceled" },
2414
  { 119, "noSuchOperation" },
2415
  { 120, "tooLate" },
2416
  { 121, "cannotCancel" },
2417
  { 0, NULL }
2418
};
2419
2420
2421
static unsigned
2422
2
dissect_ldap_T_resultCode(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2423
2424
2
  const char *valstr;
2425
2
  unsigned result;
2426
2427
2
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2428
2
                                  &result);
2429
2430
2431
2
  ldap_do_protocolop(actx->pinfo);
2432
2433
2
  valstr = val_to_str(actx->pinfo->pool, result, ldap_T_resultCode_vals, "Unknown result(%u)");
2434
2435
2
  col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
2436
2437
2
  if(ldm_tree)
2438
0
    proto_item_append_text(ldm_tree, " %s", valstr);
2439
2440
2441
2442
2
  return offset;
2443
2
}
2444
2445
2446
static const ber_sequence_t LDAPResult_sequence[] = {
2447
  { &hf_ldap_resultCode     , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_resultCode },
2448
  { &hf_ldap_matchedDN      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2449
  { &hf_ldap_errorMessage   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ErrorMessage },
2450
  { &hf_ldap_referral       , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Referral },
2451
  { NULL, 0, 0, 0, NULL }
2452
};
2453
2454
static unsigned
2455
18
dissect_ldap_LDAPResult(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2456
18
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2457
18
                                   LDAPResult_sequence, hf_index, ett_ldap_LDAPResult);
2458
2459
18
  return offset;
2460
18
}
2461
2462
2463
2464
static unsigned
2465
7
dissect_ldap_SearchResultDone(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2466
7
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2467
7
                                      hf_index, BER_CLASS_APP, 5, true, dissect_ldap_LDAPResult);
2468
2469
7
  return offset;
2470
7
}
2471
2472
2473
static const ber_sequence_t SEQUENCE_OF_LDAPURL_sequence_of[1] = {
2474
  { &hf_ldap__untag_item    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPURL },
2475
};
2476
2477
static unsigned
2478
19
dissect_ldap_SEQUENCE_OF_LDAPURL(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2479
19
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2480
19
                                      SEQUENCE_OF_LDAPURL_sequence_of, hf_index, ett_ldap_SEQUENCE_OF_LDAPURL);
2481
2482
19
  return offset;
2483
19
}
2484
2485
2486
2487
static unsigned
2488
19
dissect_ldap_SearchResultReference(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2489
2490
19
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2491
19
                                      hf_index, BER_CLASS_APP, 19, true, dissect_ldap_SEQUENCE_OF_LDAPURL);
2492
2493
2494
19
  ldap_do_protocolop(actx->pinfo);
2495
2496
2497
2498
19
  return offset;
2499
19
}
2500
2501
2502
static const value_string ldap_T_operation_vals[] = {
2503
  {   0, "add" },
2504
  {   1, "delete" },
2505
  {   2, "replace" },
2506
  {   3, "increment" },
2507
  { 0, NULL }
2508
};
2509
2510
2511
static unsigned
2512
0
dissect_ldap_T_operation(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2513
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2514
0
                                  NULL);
2515
2516
0
  return offset;
2517
0
}
2518
2519
2520
static const ber_sequence_t AttributeTypeAndValues_sequence[] = {
2521
  { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2522
  { &hf_ldap_vals           , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_AttributeValue },
2523
  { NULL, 0, 0, 0, NULL }
2524
};
2525
2526
static unsigned
2527
0
dissect_ldap_AttributeTypeAndValues(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2528
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2529
0
                                   AttributeTypeAndValues_sequence, hf_index, ett_ldap_AttributeTypeAndValues);
2530
2531
0
  return offset;
2532
0
}
2533
2534
2535
static const ber_sequence_t T_modifyRequest_modification_item_sequence[] = {
2536
  { &hf_ldap_operation      , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_operation },
2537
  { &hf_ldap_modification   , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeTypeAndValues },
2538
  { NULL, 0, 0, 0, NULL }
2539
};
2540
2541
static unsigned
2542
0
dissect_ldap_T_modifyRequest_modification_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2543
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2544
0
                                   T_modifyRequest_modification_item_sequence, hf_index, ett_ldap_T_modifyRequest_modification_item);
2545
2546
0
  return offset;
2547
0
}
2548
2549
2550
static const ber_sequence_t ModifyRequest_modification_sequence_of[1] = {
2551
  { &hf_ldap_modifyRequest_modification_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_T_modifyRequest_modification_item },
2552
};
2553
2554
static unsigned
2555
0
dissect_ldap_ModifyRequest_modification(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2556
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2557
0
                                      ModifyRequest_modification_sequence_of, hf_index, ett_ldap_ModifyRequest_modification);
2558
2559
0
  return offset;
2560
0
}
2561
2562
2563
static const ber_sequence_t ModifyRequest_U_sequence[] = {
2564
  { &hf_ldap_object         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2565
  { &hf_ldap_modifyRequest_modification, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyRequest_modification },
2566
  { NULL, 0, 0, 0, NULL }
2567
};
2568
2569
static unsigned
2570
1
dissect_ldap_ModifyRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2571
1
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2572
1
                                   ModifyRequest_U_sequence, hf_index, ett_ldap_ModifyRequest_U);
2573
2574
1
  return offset;
2575
1
}
2576
2577
2578
2579
static unsigned
2580
1
dissect_ldap_ModifyRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2581
1
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2582
1
                                      hf_index, BER_CLASS_APP, 6, true, dissect_ldap_ModifyRequest_U);
2583
2584
1
  return offset;
2585
1
}
2586
2587
2588
2589
static unsigned
2590
2
dissect_ldap_ModifyResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2591
2
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2592
2
                                      hf_index, BER_CLASS_APP, 7, true, dissect_ldap_LDAPResult);
2593
2594
2
  return offset;
2595
2
}
2596
2597
2598
static const ber_sequence_t AttributeList_item_sequence[] = {
2599
  { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2600
  { &hf_ldap_vals           , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_AttributeValue },
2601
  { NULL, 0, 0, 0, NULL }
2602
};
2603
2604
static unsigned
2605
0
dissect_ldap_AttributeList_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2606
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2607
0
                                   AttributeList_item_sequence, hf_index, ett_ldap_AttributeList_item);
2608
2609
0
  return offset;
2610
0
}
2611
2612
2613
static const ber_sequence_t AttributeList_sequence_of[1] = {
2614
  { &hf_ldap_AttributeList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeList_item },
2615
};
2616
2617
static unsigned
2618
0
dissect_ldap_AttributeList(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2619
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2620
0
                                      AttributeList_sequence_of, hf_index, ett_ldap_AttributeList);
2621
2622
0
  return offset;
2623
0
}
2624
2625
2626
static const ber_sequence_t AddRequest_U_sequence[] = {
2627
  { &hf_ldap_entry          , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2628
  { &hf_ldap_attributes     , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeList },
2629
  { NULL, 0, 0, 0, NULL }
2630
};
2631
2632
static unsigned
2633
3
dissect_ldap_AddRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2634
3
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2635
3
                                   AddRequest_U_sequence, hf_index, ett_ldap_AddRequest_U);
2636
2637
3
  return offset;
2638
3
}
2639
2640
2641
2642
static unsigned
2643
3
dissect_ldap_AddRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2644
3
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2645
3
                                      hf_index, BER_CLASS_APP, 8, true, dissect_ldap_AddRequest_U);
2646
2647
3
  return offset;
2648
3
}
2649
2650
2651
2652
static unsigned
2653
2
dissect_ldap_AddResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2654
2
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2655
2
                                      hf_index, BER_CLASS_APP, 9, true, dissect_ldap_LDAPResult);
2656
2657
2
  return offset;
2658
2
}
2659
2660
2661
2662
static unsigned
2663
17
dissect_ldap_DelRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2664
17
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2665
17
                                      hf_index, BER_CLASS_APP, 10, true, dissect_ldap_LDAPDN);
2666
2667
17
  return offset;
2668
17
}
2669
2670
2671
2672
static unsigned
2673
2
dissect_ldap_DelResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2674
2
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2675
2
                                      hf_index, BER_CLASS_APP, 11, true, dissect_ldap_LDAPResult);
2676
2677
2
  return offset;
2678
2
}
2679
2680
2681
2682
static unsigned
2683
0
dissect_ldap_RelativeLDAPDN(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2684
0
  offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
2685
2686
0
  return offset;
2687
0
}
2688
2689
2690
static const ber_sequence_t ModifyDNRequest_U_sequence[] = {
2691
  { &hf_ldap_entry          , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2692
  { &hf_ldap_newrdn         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_RelativeLDAPDN },
2693
  { &hf_ldap_deleteoldrdn   , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
2694
  { &hf_ldap_newSuperior    , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_LDAPDN },
2695
  { NULL, 0, 0, 0, NULL }
2696
};
2697
2698
static unsigned
2699
3
dissect_ldap_ModifyDNRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2700
3
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2701
3
                                   ModifyDNRequest_U_sequence, hf_index, ett_ldap_ModifyDNRequest_U);
2702
2703
3
  return offset;
2704
3
}
2705
2706
2707
2708
static unsigned
2709
3
dissect_ldap_ModifyDNRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2710
3
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2711
3
                                      hf_index, BER_CLASS_APP, 12, true, dissect_ldap_ModifyDNRequest_U);
2712
2713
3
  return offset;
2714
3
}
2715
2716
2717
2718
static unsigned
2719
3
dissect_ldap_ModifyDNResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2720
3
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2721
3
                                      hf_index, BER_CLASS_APP, 13, true, dissect_ldap_LDAPResult);
2722
2723
3
  return offset;
2724
3
}
2725
2726
2727
static const ber_sequence_t CompareRequest_U_sequence[] = {
2728
  { &hf_ldap_entry          , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2729
  { &hf_ldap_ava            , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeValueAssertion },
2730
  { NULL, 0, 0, 0, NULL }
2731
};
2732
2733
static unsigned
2734
3
dissect_ldap_CompareRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2735
3
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2736
3
                                   CompareRequest_U_sequence, hf_index, ett_ldap_CompareRequest_U);
2737
2738
3
  return offset;
2739
3
}
2740
2741
2742
2743
static unsigned
2744
3
dissect_ldap_CompareRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2745
3
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2746
3
                                      hf_index, BER_CLASS_APP, 14, true, dissect_ldap_CompareRequest_U);
2747
2748
3
  return offset;
2749
3
}
2750
2751
2752
2753
static unsigned
2754
2
dissect_ldap_CompareResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2755
2
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2756
2
                                      hf_index, BER_CLASS_APP, 15, true, dissect_ldap_LDAPResult);
2757
2758
2
  return offset;
2759
2
}
2760
2761
2762
2763
static unsigned
2764
9
dissect_ldap_AbandonRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2765
2766
9
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2767
9
                                      hf_index, BER_CLASS_APP, 16, true, dissect_ldap_MessageID);
2768
2769
2770
9
  ldap_do_protocolop(actx->pinfo);
2771
2772
2773
9
  return offset;
2774
9
}
2775
2776
2777
2778
static unsigned
2779
0
dissect_ldap_LDAPOID(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2780
2781
0
  tvbuff_t  *parameter_tvb;
2782
0
  const char *name;
2783
0
  ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)actx->private_data;
2784
2785
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2786
0
                                       &parameter_tvb);
2787
2788
2789
0
  object_identifier_id = NULL;
2790
2791
0
  if (!parameter_tvb)
2792
0
    return offset;
2793
2794
0
  object_identifier_id = (char*)tvb_get_string_enc(actx->pinfo->pool, parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
2795
0
  name = oid_resolved_from_string(actx->pinfo->pool, object_identifier_id);
2796
2797
0
  if(name){
2798
0
    proto_item_append_text(actx->created_item, " (%s)", name);
2799
2800
0
    if((hf_index == hf_ldap_requestName) || (hf_index == hf_ldap_responseName)) {
2801
0
      ldap_do_protocolop(actx->pinfo);
2802
0
      col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", name);
2803
0
    }
2804
0
  }
2805
2806
  /* Has the client requested the Start TLS operation? */
2807
0
  if (ldap_info && hf_index == hf_ldap_requestName &&
2808
0
    !strcmp(object_identifier_id, "1.3.6.1.4.1.1466.20037")) {
2809
    /* remember we have asked to start_tls */
2810
0
    ldap_info->start_tls_pending = true;
2811
0
  }
2812
2813
0
  return offset;
2814
0
}
2815
2816
2817
2818
static unsigned
2819
0
dissect_ldap_T_requestValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2820
2821
0
  if((object_identifier_id != NULL) && oid_has_dissector(object_identifier_id)) {
2822
0
    offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL);
2823
0
  } else {
2824
0
      offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2825
0
                                       NULL);
2826
2827
0
  }
2828
2829
2830
0
  return offset;
2831
0
}
2832
2833
2834
static const ber_sequence_t ExtendedRequest_U_sequence[] = {
2835
  { &hf_ldap_requestName    , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPOID },
2836
  { &hf_ldap_requestValue   , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_requestValue },
2837
  { NULL, 0, 0, 0, NULL }
2838
};
2839
2840
static unsigned
2841
3
dissect_ldap_ExtendedRequest_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2842
3
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2843
3
                                   ExtendedRequest_U_sequence, hf_index, ett_ldap_ExtendedRequest_U);
2844
2845
3
  return offset;
2846
3
}
2847
2848
2849
2850
static unsigned
2851
3
dissect_ldap_ExtendedRequest(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2852
3
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2853
3
                                      hf_index, BER_CLASS_APP, 23, true, dissect_ldap_ExtendedRequest_U);
2854
2855
3
  return offset;
2856
3
}
2857
2858
2859
static const value_string ldap_ExtendedResponse_resultCode_vals[] = {
2860
  {   0, "success" },
2861
  {   1, "operationsError" },
2862
  {   2, "protocolError" },
2863
  {   3, "timeLimitExceeded" },
2864
  {   4, "sizeLimitExceeded" },
2865
  {   5, "compareFalse" },
2866
  {   6, "compareTrue" },
2867
  {   7, "authMethodNotSupported" },
2868
  {   8, "strongAuthRequired" },
2869
  {  10, "referral" },
2870
  {  11, "adminLimitExceeded" },
2871
  {  12, "unavailableCriticalExtension" },
2872
  {  13, "confidentialityRequired" },
2873
  {  14, "saslBindInProgress" },
2874
  {  16, "noSuchAttribute" },
2875
  {  17, "undefinedAttributeType" },
2876
  {  18, "inappropriateMatching" },
2877
  {  19, "constraintViolation" },
2878
  {  20, "attributeOrValueExists" },
2879
  {  21, "invalidAttributeSyntax" },
2880
  {  32, "noSuchObject" },
2881
  {  33, "aliasProblem" },
2882
  {  34, "invalidDNSyntax" },
2883
  {  36, "aliasDereferencingProblem" },
2884
  {  48, "inappropriateAuthentication" },
2885
  {  49, "invalidCredentials" },
2886
  {  50, "insufficientAccessRights" },
2887
  {  51, "busy" },
2888
  {  52, "unavailable" },
2889
  {  53, "unwillingToPerform" },
2890
  {  54, "loopDetect" },
2891
  {  64, "namingViolation" },
2892
  {  65, "objectClassViolation" },
2893
  {  66, "notAllowedOnNonLeaf" },
2894
  {  67, "notAllowedOnRDN" },
2895
  {  68, "entryAlreadyExists" },
2896
  {  69, "objectClassModsProhibited" },
2897
  {  71, "affectsMultipleDSAs" },
2898
  {  80, "other" },
2899
  { 118, "canceled" },
2900
  { 119, "noSuchOperation" },
2901
  { 120, "tooLate" },
2902
  { 121, "cannotCancel" },
2903
  { 0, NULL }
2904
};
2905
2906
2907
static unsigned
2908
0
dissect_ldap_ExtendedResponse_resultCode(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2909
0
  uint32_t resultCode;
2910
0
  ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)actx->private_data;
2911
2912
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2913
0
                               &resultCode);
2914
  /* If Start TLS request was sent and resultCode is success... */
2915
0
  if (ldap_info && ldap_info->start_tls_pending &&
2916
0
      hf_index == hf_ldap_extendedResponse_resultCode && resultCode == 0) {
2917
    /* The conversation will continue using SSL */
2918
0
    ssl_starttls_ack(find_dissector("tls"), actx->pinfo, ldap_handle);
2919
0
    ldap_info->start_tls_pending = false;
2920
0
  }
2921
2922
2923
2924
0
  return offset;
2925
0
}
2926
2927
2928
2929
static unsigned
2930
0
dissect_ldap_ResponseName(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2931
0
  offset = dissect_ldap_LDAPOID(implicit_tag, tvb, offset, actx, tree, hf_index);
2932
2933
0
  return offset;
2934
0
}
2935
2936
2937
2938
static unsigned
2939
0
dissect_ldap_OCTET_STRING(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2940
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2941
0
                                       NULL);
2942
2943
0
  return offset;
2944
0
}
2945
2946
2947
static const ber_sequence_t ExtendedResponse_U_sequence[] = {
2948
  { &hf_ldap_extendedResponse_resultCode, BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_ExtendedResponse_resultCode },
2949
  { &hf_ldap_matchedDN      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2950
  { &hf_ldap_errorMessage   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ErrorMessage },
2951
  { &hf_ldap_referral       , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Referral },
2952
  { &hf_ldap_responseName   , BER_CLASS_CON, 10, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_ResponseName },
2953
  { &hf_ldap_response       , BER_CLASS_CON, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
2954
  { NULL, 0, 0, 0, NULL }
2955
};
2956
2957
static unsigned
2958
4
dissect_ldap_ExtendedResponse_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2959
4
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2960
4
                                   ExtendedResponse_U_sequence, hf_index, ett_ldap_ExtendedResponse_U);
2961
2962
4
  return offset;
2963
4
}
2964
2965
2966
2967
static unsigned
2968
4
dissect_ldap_ExtendedResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2969
4
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2970
4
                                      hf_index, BER_CLASS_APP, 24, true, dissect_ldap_ExtendedResponse_U);
2971
2972
4
  return offset;
2973
4
}
2974
2975
2976
2977
static unsigned
2978
0
dissect_ldap_T_intermediateResponse_responseValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2979
2980
0
  const char *name;
2981
2982
0
  if(ldm_tree && object_identifier_id) {
2983
0
    proto_item_set_text(ldm_tree, "%s %s", "IntermediateResponse", object_identifier_id);
2984
0
    name = oid_resolved_from_string(actx->pinfo->pool, object_identifier_id);
2985
0
    if(name)
2986
0
      proto_item_append_text(ldm_tree, " (%s)", name);
2987
0
  }
2988
0
  if((object_identifier_id != NULL) && oid_has_dissector(object_identifier_id)) {
2989
0
    offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL);
2990
0
  } else {
2991
0
      offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2992
0
                                       NULL);
2993
2994
0
  }
2995
2996
2997
0
  return offset;
2998
0
}
2999
3000
3001
static const ber_sequence_t IntermediateResponse_U_sequence[] = {
3002
  { &hf_ldap_responseName   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_ResponseName },
3003
  { &hf_ldap_intermediateResponse_responseValue, BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_intermediateResponse_responseValue },
3004
  { NULL, 0, 0, 0, NULL }
3005
};
3006
3007
static unsigned
3008
2
dissect_ldap_IntermediateResponse_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3009
2
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3010
2
                                   IntermediateResponse_U_sequence, hf_index, ett_ldap_IntermediateResponse_U);
3011
3012
2
  return offset;
3013
2
}
3014
3015
3016
3017
static unsigned
3018
2
dissect_ldap_IntermediateResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3019
2
  offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3020
2
                                      hf_index, BER_CLASS_APP, 25, true, dissect_ldap_IntermediateResponse_U);
3021
3022
2
  return offset;
3023
2
}
3024
3025
3026
static const value_string ldap_ProtocolOp_vals[] = {
3027
  {   0, "bindRequest" },
3028
  {   1, "bindResponse" },
3029
  {   2, "unbindRequest" },
3030
  {   3, "searchRequest" },
3031
  {   4, "searchResEntry" },
3032
  {   5, "searchResDone" },
3033
  {  19, "searchResRef" },
3034
  {   6, "modifyRequest" },
3035
  {   7, "modifyResponse" },
3036
  {   8, "addRequest" },
3037
  {   9, "addResponse" },
3038
  {  10, "delRequest" },
3039
  {  11, "delResponse" },
3040
  {  12, "modDNRequest" },
3041
  {  13, "modDNResponse" },
3042
  {  14, "compareRequest" },
3043
  {  15, "compareResponse" },
3044
  {  16, "abandonRequest" },
3045
  {  23, "extendedReq" },
3046
  {  24, "extendedResp" },
3047
  {  25, "intermediateResponse" },
3048
  { 0, NULL }
3049
};
3050
3051
static const ber_choice_t ProtocolOp_choice[] = {
3052
  {   0, &hf_ldap_bindRequest    , BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_ldap_BindRequest },
3053
  {   1, &hf_ldap_bindResponse   , BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_ldap_BindResponse },
3054
  {   2, &hf_ldap_unbindRequest  , BER_CLASS_APP, 2, BER_FLAGS_NOOWNTAG, dissect_ldap_UnbindRequest },
3055
  {   3, &hf_ldap_searchRequest  , BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchRequest },
3056
  {   4, &hf_ldap_searchResEntry , BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchResultEntry },
3057
  {   5, &hf_ldap_searchResDone  , BER_CLASS_APP, 5, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchResultDone },
3058
  {  19, &hf_ldap_searchResRef   , BER_CLASS_APP, 19, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchResultReference },
3059
  {   6, &hf_ldap_modifyRequest  , BER_CLASS_APP, 6, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyRequest },
3060
  {   7, &hf_ldap_modifyResponse , BER_CLASS_APP, 7, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyResponse },
3061
  {   8, &hf_ldap_addRequest     , BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_ldap_AddRequest },
3062
  {   9, &hf_ldap_addResponse    , BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_ldap_AddResponse },
3063
  {  10, &hf_ldap_delRequest     , BER_CLASS_APP, 10, BER_FLAGS_NOOWNTAG, dissect_ldap_DelRequest },
3064
  {  11, &hf_ldap_delResponse    , BER_CLASS_APP, 11, BER_FLAGS_NOOWNTAG, dissect_ldap_DelResponse },
3065
  {  12, &hf_ldap_modDNRequest   , BER_CLASS_APP, 12, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyDNRequest },
3066
  {  13, &hf_ldap_modDNResponse  , BER_CLASS_APP, 13, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyDNResponse },
3067
  {  14, &hf_ldap_compareRequest , BER_CLASS_APP, 14, BER_FLAGS_NOOWNTAG, dissect_ldap_CompareRequest },
3068
  {  15, &hf_ldap_compareResponse, BER_CLASS_APP, 15, BER_FLAGS_NOOWNTAG, dissect_ldap_CompareResponse },
3069
  {  16, &hf_ldap_abandonRequest , BER_CLASS_APP, 16, BER_FLAGS_NOOWNTAG, dissect_ldap_AbandonRequest },
3070
  {  23, &hf_ldap_extendedReq    , BER_CLASS_APP, 23, BER_FLAGS_NOOWNTAG, dissect_ldap_ExtendedRequest },
3071
  {  24, &hf_ldap_extendedResp   , BER_CLASS_APP, 24, BER_FLAGS_NOOWNTAG, dissect_ldap_ExtendedResponse },
3072
  {  25, &hf_ldap_intermediateResponse, BER_CLASS_APP, 25, BER_FLAGS_NOOWNTAG, dissect_ldap_IntermediateResponse },
3073
  { 0, NULL, 0, 0, 0, NULL }
3074
};
3075
3076
static unsigned
3077
163
dissect_ldap_ProtocolOp(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3078
3079
163
  ldap_call_response_t *lcrp;
3080
163
  ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)actx->private_data;
3081
163
  do_protocolop = true;
3082
3083
163
  offset = dissect_ber_choice(actx, tree, tvb, offset,
3084
163
                                 ProtocolOp_choice, hf_index, ett_ldap_ProtocolOp,
3085
163
                                 &ProtocolOp);
3086
3087
3088
163
  if (ProtocolOp == -1) {
3089
46
    return offset;
3090
46
  }
3091
3092
  /* ProtocolOp is the index, not the tag so convert it to the tag value */
3093
117
  ProtocolOp = ldap_ProtocolOp_vals[ProtocolOp].value;
3094
3095
117
  lcrp=ldap_match_call_response(tvb, actx->pinfo, tree, MessageID, ProtocolOp, ldap_info);
3096
117
  if(lcrp){
3097
4
    tap_queue_packet(ldap_tap, actx->pinfo, lcrp);
3098
4
  }
3099
3100
  /* XXX: the count will not work if the results span multiple TCP packets */
3101
3102
117
  if(ldap_info) { /* only count once */
3103
35
    switch(ProtocolOp) {
3104
3105
6
    case LDAP_RES_SEARCH_ENTRY:
3106
6
      if (!actx->pinfo->fd->visited)
3107
6
        ldap_info->num_results++;
3108
3109
6
      proto_item_append_text(tree, " [%d result%s]",
3110
6
                             ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
3111
3112
6
    break;
3113
3114
1
    case LDAP_RES_SEARCH_RESULT:
3115
3116
1
      col_append_fstr(actx->pinfo->cinfo, COL_INFO, " [%d result%s]",
3117
1
                      ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
3118
3119
1
      proto_item_append_text(tree, " [%d result%s]",
3120
1
                             ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
3121
3122
1
    break;
3123
28
    default:
3124
28
    break;
3125
35
    }
3126
35
  }
3127
3128
3129
117
  return offset;
3130
117
}
3131
3132
3133
3134
static unsigned
3135
0
dissect_ldap_ControlType(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3136
0
  offset = dissect_ldap_LDAPOID(implicit_tag, tvb, offset, actx, tree, hf_index);
3137
3138
0
  return offset;
3139
0
}
3140
3141
3142
3143
static unsigned
3144
0
dissect_ldap_T_controlValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3145
0
  int8_t ber_class;
3146
0
  bool pc, ind;
3147
0
  int32_t tag;
3148
0
  uint32_t len;
3149
3150
0
  if((object_identifier_id != NULL) && oid_has_dissector(object_identifier_id)) {
3151
    /* remove the OCTET STRING encoding */
3152
0
    offset=dissect_ber_identifier(actx->pinfo, NULL, tvb, offset, &ber_class, &pc, &tag);
3153
0
    offset=dissect_ber_length(actx->pinfo, NULL, tvb, offset, &len, &ind);
3154
3155
0
    call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL);
3156
3157
0
    offset += len;
3158
0
  } else {
3159
0
      offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
3160
0
                                       NULL);
3161
3162
0
  }
3163
3164
3165
3166
0
  return offset;
3167
0
}
3168
3169
3170
static const ber_sequence_t Control_sequence[] = {
3171
  { &hf_ldap_controlType    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ControlType },
3172
  { &hf_ldap_criticality    , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3173
  { &hf_ldap_controlValue   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_T_controlValue },
3174
  { NULL, 0, 0, 0, NULL }
3175
};
3176
3177
static unsigned
3178
0
dissect_ldap_Control(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3179
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3180
0
                                   Control_sequence, hf_index, ett_ldap_Control);
3181
3182
0
  return offset;
3183
0
}
3184
3185
3186
static const ber_sequence_t Controls_sequence_of[1] = {
3187
  { &hf_ldap_Controls_item  , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_Control },
3188
};
3189
3190
static unsigned
3191
2
dissect_ldap_Controls(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3192
2
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
3193
2
                                      Controls_sequence_of, hf_index, ett_ldap_Controls);
3194
3195
2
  return offset;
3196
2
}
3197
3198
3199
static const ber_sequence_t LDAPMessage_sequence[] = {
3200
  { &hf_ldap_messageID      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_MessageID },
3201
  { &hf_ldap_protocolOp     , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_ProtocolOp },
3202
  { &hf_ldap_controls       , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Controls },
3203
  { NULL, 0, 0, 0, NULL }
3204
};
3205
3206
static unsigned
3207
492
dissect_ldap_LDAPMessage(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3208
492
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3209
492
                                   LDAPMessage_sequence, hf_index, ett_ldap_LDAPMessage);
3210
3211
492
  return offset;
3212
492
}
3213
3214
3215
3216
3217
3218
static unsigned
3219
0
dissect_ldap_INTEGER(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3220
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3221
0
                                                NULL);
3222
3223
0
  return offset;
3224
0
}
3225
3226
3227
static const ber_sequence_t SearchControlValue_sequence[] = {
3228
  { &hf_ldap_size           , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER },
3229
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3230
  { NULL, 0, 0, 0, NULL }
3231
};
3232
3233
static unsigned
3234
0
dissect_ldap_SearchControlValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3235
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3236
0
                                   SearchControlValue_sequence, hf_index, ett_ldap_SearchControlValue);
3237
3238
0
  return offset;
3239
0
}
3240
3241
3242
static const ber_sequence_t SortKeyList_item_sequence[] = {
3243
  { &hf_ldap_attributeType  , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
3244
  { &hf_ldap_orderingRule   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_MatchingRuleId },
3245
  { &hf_ldap_reverseOrder   , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_BOOLEAN },
3246
  { NULL, 0, 0, 0, NULL }
3247
};
3248
3249
static unsigned
3250
0
dissect_ldap_SortKeyList_item(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3251
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3252
0
                                   SortKeyList_item_sequence, hf_index, ett_ldap_SortKeyList_item);
3253
3254
0
  return offset;
3255
0
}
3256
3257
3258
static const ber_sequence_t SortKeyList_sequence_of[1] = {
3259
  { &hf_ldap_SortKeyList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_SortKeyList_item },
3260
};
3261
3262
static unsigned
3263
0
dissect_ldap_SortKeyList(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3264
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
3265
0
                                      SortKeyList_sequence_of, hf_index, ett_ldap_SortKeyList);
3266
3267
0
  return offset;
3268
0
}
3269
3270
3271
static const value_string ldap_T_sortResult_vals[] = {
3272
  {   0, "success" },
3273
  {   1, "operationsError" },
3274
  {   3, "timeLimitExceeded" },
3275
  {   8, "strongAuthRequired" },
3276
  {  11, "adminLimitExceeded" },
3277
  {  16, "noSuchAttribute" },
3278
  {  18, "inappropriateMatching" },
3279
  {  50, "insufficientAccessRights" },
3280
  {  51, "busy" },
3281
  {  53, "unwillingToPerform" },
3282
  {  80, "other" },
3283
  { 0, NULL }
3284
};
3285
3286
3287
static unsigned
3288
0
dissect_ldap_T_sortResult(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3289
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3290
0
                                  NULL);
3291
3292
0
  return offset;
3293
0
}
3294
3295
3296
static const ber_sequence_t SortResult_sequence[] = {
3297
  { &hf_ldap_sortResult     , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_sortResult },
3298
  { &hf_ldap_attributeType  , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_AttributeDescription },
3299
  { NULL, 0, 0, 0, NULL }
3300
};
3301
3302
static unsigned
3303
0
dissect_ldap_SortResult(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3304
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3305
0
                                   SortResult_sequence, hf_index, ett_ldap_SortResult);
3306
3307
0
  return offset;
3308
0
}
3309
3310
3311
3312
static unsigned
3313
0
dissect_ldap_DirSyncFlags(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3314
0
  int8_t ber_class;
3315
0
  bool pc;
3316
0
  int32_t tag;
3317
0
  uint32_t len;
3318
0
  uint32_t val;
3319
3320
0
  int otheroffset = offset;
3321
0
  if(!implicit_tag){
3322
0
    dissect_ber_identifier(actx->pinfo, tree, tvb, otheroffset, &ber_class, &pc, &tag);
3323
0
    otheroffset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, NULL);
3324
0
  } else {
3325
0
    int32_t remaining=tvb_reported_length_remaining(tvb, offset);
3326
0
    len=remaining>0 ? remaining : 0;
3327
0
  }
3328
3329
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, -1, &val);
3330
3331
0
  if (val >0) {
3332
0
    static int * const flags[] = {
3333
0
      &hf_ldap_object_security_flag,
3334
0
      &hf_ldap_ancestor_first_flag,
3335
0
      &hf_ldap_public_data_only_flag,
3336
0
      &hf_ldap_incremental_value_flag,
3337
0
      NULL
3338
0
    };
3339
3340
0
    proto_tree_add_bitmask_value_with_flags(tree, tvb, otheroffset+1, hf_index,
3341
0
                                            ett_ldap_DirSyncFlagsSubEntry, flags, val, BMT_NO_APPEND);
3342
0
  } else {
3343
0
    proto_tree_add_uint(tree, hf_index, tvb, otheroffset+len, len, 0);
3344
0
  }
3345
3346
3347
0
  return offset;
3348
0
}
3349
3350
3351
static const ber_sequence_t DirSyncControlValue_sequence[] = {
3352
  { &hf_ldap_flags          , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_DirSyncFlags },
3353
  { &hf_ldap_maxBytes       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER },
3354
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3355
  { NULL, 0, 0, 0, NULL }
3356
};
3357
3358
static unsigned
3359
0
dissect_ldap_DirSyncControlValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3360
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3361
0
                                   DirSyncControlValue_sequence, hf_index, ett_ldap_DirSyncControlValue);
3362
3363
0
  return offset;
3364
0
}
3365
3366
3367
static const ber_sequence_t PasswdModifyRequestValue_sequence[] = {
3368
  { &hf_ldap_userIdentity   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3369
  { &hf_ldap_oldPasswd      , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3370
  { &hf_ldap_newPasswd      , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3371
  { NULL, 0, 0, 0, NULL }
3372
};
3373
3374
static unsigned
3375
0
dissect_ldap_PasswdModifyRequestValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3376
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3377
0
                                   PasswdModifyRequestValue_sequence, hf_index, ett_ldap_PasswdModifyRequestValue);
3378
3379
0
  return offset;
3380
0
}
3381
3382
3383
static const ber_sequence_t CancelRequestValue_sequence[] = {
3384
  { &hf_ldap_cancelID       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_MessageID },
3385
  { NULL, 0, 0, 0, NULL }
3386
};
3387
3388
static unsigned
3389
0
dissect_ldap_CancelRequestValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3390
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3391
0
                                   CancelRequestValue_sequence, hf_index, ett_ldap_CancelRequestValue);
3392
3393
0
  return offset;
3394
0
}
3395
3396
3397
static const value_string ldap_T_mode_vals[] = {
3398
  {   1, "refreshOnly" },
3399
  {   3, "refreshAndPersist" },
3400
  { 0, NULL }
3401
};
3402
3403
3404
static unsigned
3405
0
dissect_ldap_T_mode(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3406
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3407
0
                                  NULL);
3408
3409
0
  return offset;
3410
0
}
3411
3412
3413
static const ber_sequence_t SyncRequestValue_sequence[] = {
3414
  { &hf_ldap_mode           , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_mode },
3415
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3416
  { &hf_ldap_reloadHint     , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3417
  { NULL, 0, 0, 0, NULL }
3418
};
3419
3420
static unsigned
3421
0
dissect_ldap_SyncRequestValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3422
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3423
0
                                   SyncRequestValue_sequence, hf_index, ett_ldap_SyncRequestValue);
3424
3425
0
  return offset;
3426
0
}
3427
3428
3429
static const value_string ldap_T_state_vals[] = {
3430
  {   0, "present" },
3431
  {   1, "add" },
3432
  {   2, "modify" },
3433
  {   3, "delete" },
3434
  { 0, NULL }
3435
};
3436
3437
3438
static unsigned
3439
0
dissect_ldap_T_state(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3440
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3441
0
                                  NULL);
3442
3443
0
  return offset;
3444
0
}
3445
3446
3447
3448
static unsigned
3449
0
dissect_ldap_SyncUUID(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3450
0
  offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset,
3451
0
                                                   16, 16, hf_index, NULL);
3452
3453
0
  return offset;
3454
0
}
3455
3456
3457
static const ber_sequence_t SyncStateValue_sequence[] = {
3458
  { &hf_ldap_state          , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_state },
3459
  { &hf_ldap_entryUUID      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_SyncUUID },
3460
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3461
  { NULL, 0, 0, 0, NULL }
3462
};
3463
3464
static unsigned
3465
0
dissect_ldap_SyncStateValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3466
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3467
0
                                   SyncStateValue_sequence, hf_index, ett_ldap_SyncStateValue);
3468
3469
0
  return offset;
3470
0
}
3471
3472
3473
static const ber_sequence_t SyncDoneValue_sequence[] = {
3474
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3475
  { &hf_ldap_refreshDeletes , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3476
  { NULL, 0, 0, 0, NULL }
3477
};
3478
3479
static unsigned
3480
0
dissect_ldap_SyncDoneValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3481
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3482
0
                                   SyncDoneValue_sequence, hf_index, ett_ldap_SyncDoneValue);
3483
3484
0
  return offset;
3485
0
}
3486
3487
3488
static const ber_sequence_t T_refreshDelete_sequence[] = {
3489
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3490
  { &hf_ldap_refreshDone    , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3491
  { NULL, 0, 0, 0, NULL }
3492
};
3493
3494
static unsigned
3495
0
dissect_ldap_T_refreshDelete(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3496
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3497
0
                                   T_refreshDelete_sequence, hf_index, ett_ldap_T_refreshDelete);
3498
3499
0
  return offset;
3500
0
}
3501
3502
3503
static const ber_sequence_t T_refreshPresent_sequence[] = {
3504
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3505
  { &hf_ldap_refreshDone    , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3506
  { NULL, 0, 0, 0, NULL }
3507
};
3508
3509
static unsigned
3510
0
dissect_ldap_T_refreshPresent(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3511
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3512
0
                                   T_refreshPresent_sequence, hf_index, ett_ldap_T_refreshPresent);
3513
3514
0
  return offset;
3515
0
}
3516
3517
3518
static const ber_sequence_t SET_OF_SyncUUID_set_of[1] = {
3519
  { &hf_ldap_syncUUIDs_item , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_SyncUUID },
3520
};
3521
3522
static unsigned
3523
0
dissect_ldap_SET_OF_SyncUUID(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3524
0
  offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
3525
0
                                 SET_OF_SyncUUID_set_of, hf_index, ett_ldap_SET_OF_SyncUUID);
3526
3527
0
  return offset;
3528
0
}
3529
3530
3531
static const ber_sequence_t T_syncIdSet_sequence[] = {
3532
  { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3533
  { &hf_ldap_refreshDeletes , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3534
  { &hf_ldap_syncUUIDs      , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_SyncUUID },
3535
  { NULL, 0, 0, 0, NULL }
3536
};
3537
3538
static unsigned
3539
0
dissect_ldap_T_syncIdSet(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3540
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3541
0
                                   T_syncIdSet_sequence, hf_index, ett_ldap_T_syncIdSet);
3542
3543
0
  return offset;
3544
0
}
3545
3546
3547
static const value_string ldap_SyncInfoValue_vals[] = {
3548
  {   0, "newcookie" },
3549
  {   1, "refreshDelete" },
3550
  {   2, "refreshPresent" },
3551
  {   3, "syncIdSet" },
3552
  { 0, NULL }
3553
};
3554
3555
static const ber_choice_t SyncInfoValue_choice[] = {
3556
  {   0, &hf_ldap_newcookie      , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3557
  {   1, &hf_ldap_refreshDelete  , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_T_refreshDelete },
3558
  {   2, &hf_ldap_refreshPresent , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ldap_T_refreshPresent },
3559
  {   3, &hf_ldap_syncIdSet      , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_T_syncIdSet },
3560
  { 0, NULL, 0, 0, 0, NULL }
3561
};
3562
3563
static unsigned
3564
0
dissect_ldap_SyncInfoValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3565
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
3566
0
                                 SyncInfoValue_choice, hf_index, ett_ldap_SyncInfoValue,
3567
0
                                 NULL);
3568
3569
0
  return offset;
3570
0
}
3571
3572
3573
static const value_string ldap_T_warning_vals[] = {
3574
  {   0, "timeBeforeExpiration" },
3575
  {   1, "graceAuthNsRemaining" },
3576
  { 0, NULL }
3577
};
3578
3579
static const ber_choice_t T_warning_choice[] = {
3580
  {   0, &hf_ldap_timeBeforeExpiration, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_INTEGER_0_maxInt },
3581
  {   1, &hf_ldap_graceAuthNsRemaining, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_INTEGER_0_maxInt },
3582
  { 0, NULL, 0, 0, 0, NULL }
3583
};
3584
3585
static unsigned
3586
0
dissect_ldap_T_warning(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3587
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
3588
0
                                 T_warning_choice, hf_index, ett_ldap_T_warning,
3589
0
                                 NULL);
3590
3591
0
  return offset;
3592
0
}
3593
3594
3595
static const value_string ldap_T_error_vals[] = {
3596
  {   0, "passwordExpired" },
3597
  {   1, "accountLocked" },
3598
  {   2, "changeAfterReset" },
3599
  {   3, "passwordModNotAllowed" },
3600
  {   4, "mustSupplyOldPassword" },
3601
  {   5, "insufficientPasswordQuality" },
3602
  {   6, "passwordTooShort" },
3603
  {   7, "passwordTooYoung" },
3604
  {   8, "passwordInHistory" },
3605
  { 0, NULL }
3606
};
3607
3608
3609
static unsigned
3610
0
dissect_ldap_T_error(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3611
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3612
0
                                  NULL);
3613
3614
0
  return offset;
3615
0
}
3616
3617
3618
static const ber_sequence_t PasswordPolicyResponseValue_sequence[] = {
3619
  { &hf_ldap_warning        , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_warning },
3620
  { &hf_ldap_error          , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_error },
3621
  { NULL, 0, 0, 0, NULL }
3622
};
3623
3624
static unsigned
3625
0
dissect_ldap_PasswordPolicyResponseValue(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3626
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3627
0
                                   PasswordPolicyResponseValue_sequence, hf_index, ett_ldap_PasswordPolicyResponseValue);
3628
3629
0
  return offset;
3630
0
}
3631
3632
/*--- PDUs ---*/
3633
3634
0
static int dissect_SearchControlValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3635
0
  unsigned offset = 0;
3636
0
  asn1_ctx_t asn1_ctx;
3637
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3638
0
  offset = dissect_ldap_SearchControlValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SearchControlValue_PDU);
3639
0
  return offset;
3640
0
}
3641
0
static int dissect_SortKeyList_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3642
0
  unsigned offset = 0;
3643
0
  asn1_ctx_t asn1_ctx;
3644
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3645
0
  offset = dissect_ldap_SortKeyList(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SortKeyList_PDU);
3646
0
  return offset;
3647
0
}
3648
0
static int dissect_SortResult_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3649
0
  unsigned offset = 0;
3650
0
  asn1_ctx_t asn1_ctx;
3651
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3652
0
  offset = dissect_ldap_SortResult(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SortResult_PDU);
3653
0
  return offset;
3654
0
}
3655
0
static int dissect_DirSyncControlValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3656
0
  unsigned offset = 0;
3657
0
  asn1_ctx_t asn1_ctx;
3658
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3659
0
  offset = dissect_ldap_DirSyncControlValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_DirSyncControlValue_PDU);
3660
0
  return offset;
3661
0
}
3662
0
static int dissect_PasswdModifyRequestValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3663
0
  unsigned offset = 0;
3664
0
  asn1_ctx_t asn1_ctx;
3665
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3666
0
  offset = dissect_ldap_PasswdModifyRequestValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_PasswdModifyRequestValue_PDU);
3667
0
  return offset;
3668
0
}
3669
0
static int dissect_CancelRequestValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3670
0
  unsigned offset = 0;
3671
0
  asn1_ctx_t asn1_ctx;
3672
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3673
0
  offset = dissect_ldap_CancelRequestValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_CancelRequestValue_PDU);
3674
0
  return offset;
3675
0
}
3676
0
static int dissect_SyncRequestValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3677
0
  unsigned offset = 0;
3678
0
  asn1_ctx_t asn1_ctx;
3679
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3680
0
  offset = dissect_ldap_SyncRequestValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncRequestValue_PDU);
3681
0
  return offset;
3682
0
}
3683
0
static int dissect_SyncStateValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3684
0
  unsigned offset = 0;
3685
0
  asn1_ctx_t asn1_ctx;
3686
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3687
0
  offset = dissect_ldap_SyncStateValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncStateValue_PDU);
3688
0
  return offset;
3689
0
}
3690
0
static int dissect_SyncDoneValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3691
0
  unsigned offset = 0;
3692
0
  asn1_ctx_t asn1_ctx;
3693
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3694
0
  offset = dissect_ldap_SyncDoneValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncDoneValue_PDU);
3695
0
  return offset;
3696
0
}
3697
0
static int dissect_SyncInfoValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3698
0
  unsigned offset = 0;
3699
0
  asn1_ctx_t asn1_ctx;
3700
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3701
0
  offset = dissect_ldap_SyncInfoValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncInfoValue_PDU);
3702
0
  return offset;
3703
0
}
3704
0
static int dissect_PasswordPolicyResponseValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3705
0
  unsigned offset = 0;
3706
0
  asn1_ctx_t asn1_ctx;
3707
0
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3708
0
  offset = dissect_ldap_PasswordPolicyResponseValue(false, tvb, offset, &asn1_ctx, tree, hf_ldap_PasswordPolicyResponseValue_PDU);
3709
0
  return offset;
3710
0
}
3711
3712
492
static int dissect_LDAPMessage_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ldap_conv_info_t *ldap_info) {
3713
3714
492
  int offset = 0;
3715
492
  asn1_ctx_t asn1_ctx;
3716
492
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
3717
3718
492
  asn1_ctx.private_data = ldap_info;
3719
492
  offset = dissect_ldap_LDAPMessage(false, tvb, offset, &asn1_ctx, tree, hf_ldap_LDAPMessage_PDU);
3720
492
  return offset;
3721
492
}
3722
3723
static void
3724
dissect_ldap_payload(tvbuff_t *tvb, packet_info *pinfo,
3725
                     proto_tree *tree, ldap_conv_info_t *ldap_info,
3726
                     bool is_mscldap)
3727
524
{
3728
524
  int offset = 0;
3729
524
  unsigned length_remaining;
3730
524
  unsigned msg_len = 0;
3731
524
  int messageOffset = 0;
3732
524
  unsigned headerLength = 0;
3733
524
  tvbuff_t *msg_tvb = NULL;
3734
524
  int8_t ber_class;
3735
524
  bool pc, ind = 0;
3736
524
  int32_t ber_tag;
3737
3738
524
  attributedesc_string=NULL;
3739
3740
3741
539
one_more_pdu:
3742
3743
539
    length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);
3744
3745
539
    if (length_remaining < 6) return;
3746
3747
    /*
3748
     * OK, try to read the "Sequence Of" header; this gets the total
3749
     * length of the LDAP message.
3750
     */
3751
535
        messageOffset = get_ber_identifier(tvb, offset, &ber_class, &pc, &ber_tag);
3752
535
        messageOffset = get_ber_length(tvb, messageOffset, &msg_len, &ind);
3753
3754
    /* sanity check */
3755
535
    if((msg_len<4) || (msg_len>10000000)) return;
3756
3757
514
    if ( (ber_class==BER_CLASS_UNI) && (ber_tag==BER_UNI_TAG_SEQUENCE) ) {
3758
        /*
3759
         * Add the length of the "Sequence Of" header to the message
3760
         * length.
3761
         */
3762
98
        headerLength = messageOffset - offset;
3763
98
        msg_len += headerLength;
3764
98
        if (msg_len < headerLength) {
3765
            /*
3766
             * The message length was probably so large that the total length
3767
             * overflowed.
3768
             *
3769
             * Report this as an error.
3770
             */
3771
0
            show_reported_bounds_error(tvb, pinfo, tree);
3772
0
            return;
3773
0
        }
3774
416
    } else {
3775
        /*
3776
         * We couldn't parse the header; just make it the amount of data
3777
         * remaining in the tvbuff, so we'll give up on this segment
3778
         * after attempting to parse the message - there's nothing more
3779
         * we can do.  "dissect_ldap_message()" will display the error.
3780
         */
3781
416
        msg_len = length_remaining;
3782
416
    }
3783
3784
    /*
3785
     * Construct a tvbuff containing the amount of the payload we have
3786
     * available.  Make its reported length the amount of data in the
3787
     * LDAP message.
3788
     */
3789
514
    msg_tvb = tvb_new_subset_length(tvb, offset, msg_len);
3790
3791
    /*
3792
     * Now dissect the LDAP message.
3793
     */
3794
514
    ldap_info->is_mscldap = is_mscldap;
3795
514
    dissect_LDAPMessage_PDU(msg_tvb, pinfo, tree, ldap_info);
3796
3797
514
    offset += msg_len;
3798
3799
    /* If this was a sasl blob there might be another PDU following in the
3800
     * same blob
3801
     */
3802
514
    if(tvb_reported_length_remaining(tvb, offset)>=6){
3803
15
        tvb = tvb_new_subset_remaining(tvb, offset);
3804
15
        offset = 0;
3805
3806
15
        goto one_more_pdu;
3807
15
    }
3808
3809
514
}
3810
3811
static void
3812
ldap_frame_end(void)
3813
184
{
3814
184
  ldap_found_in_frame = false;
3815
184
  attr_type = NULL;
3816
184
  ldapvalue_string = NULL;
3817
/* ? */
3818
184
  attributedesc_string = NULL;
3819
184
  Filter_string = NULL;
3820
184
  and_filter_string = NULL;
3821
184
  object_identifier_id = NULL;
3822
184
  or_filter_string = NULL;
3823
3824
184
  substring_item_any = NULL;
3825
184
  substring_item_final = NULL;
3826
184
  substring_item_init = NULL;
3827
184
  substring_value = NULL;
3828
3829
184
  ldm_tree = NULL;
3830
3831
184
  Filter_elements = 0;
3832
184
  Filter_length = 0;
3833
184
  do_protocolop = false;
3834
3835
/* seems to be ok, but reset just in case */
3836
184
  matching_rule_string = NULL;
3837
184
}
3838
3839
static void
3840
  dissect_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bool is_mscldap)
3841
524
{
3842
524
  int offset = 0;
3843
524
  conversation_t *conversation;
3844
524
  bool doing_sasl_security = false;
3845
524
  ldap_conv_info_t *ldap_info = NULL;
3846
524
  proto_item *ldap_item = NULL;
3847
524
  proto_tree *ldap_tree = NULL;
3848
524
  uint32_t sasl_length = 0;
3849
524
  uint32_t remaining_length = 0;
3850
524
  uint8_t sasl_start[2] = { 0, };
3851
524
  bool detected_sasl_security = false;
3852
3853
524
  ldm_tree = NULL;
3854
3855
524
  conversation = find_or_create_conversation(pinfo);
3856
3857
  /*
3858
  * Do we already have a type and mechanism?
3859
  */
3860
524
  ldap_info = (ldap_conv_info_t *)conversation_get_proto_data(conversation, proto_ldap);
3861
524
  if (ldap_info == NULL) {
3862
    /* No.  Attach that information to the conversation, and add
3863
    * it to the list of information structures.
3864
    */
3865
77
    ldap_info = wmem_new0(wmem_file_scope(), ldap_conv_info_t);
3866
77
    ldap_info->matched=wmem_map_new(wmem_file_scope(), ldap_info_hash_matched, ldap_info_equal_matched);
3867
77
    ldap_info->unmatched=wmem_map_new(wmem_file_scope(), ldap_info_hash_unmatched, ldap_info_equal_unmatched);
3868
3869
77
    conversation_add_proto_data(conversation, proto_ldap, ldap_info);
3870
77
  }
3871
3872
524
  switch (ldap_info->auth_type) {
3873
87
  case LDAP_AUTH_SASL:
3874
    /*
3875
    * It's SASL; are we using a security layer?
3876
    */
3877
87
    if (ldap_info->first_auth_frame != 0 &&
3878
87
      pinfo->num >= ldap_info->first_auth_frame) {
3879
87
        doing_sasl_security = true; /* yes */
3880
87
    }
3881
524
  }
3882
3883
524
  tvb_ensure_captured_length_remaining(tvb, offset);
3884
3885
  /* It might still be a packet containing a SASL security layer
3886
  * but it's just that we never saw the BIND packet.
3887
  * check if it looks like it could be a SASL blob here
3888
  * and in that case just assume it is GSS-SPNEGO
3889
  */
3890
524
  if(!doing_sasl_security && tvb_bytes_exist(tvb, offset, 6)) {
3891
433
      sasl_length = tvb_get_ntohl(tvb, offset);
3892
433
      remaining_length = tvb_reported_length_remaining(tvb, offset);
3893
433
      sasl_start[0] = tvb_get_uint8(tvb, offset+4);
3894
433
      sasl_start[1] = tvb_get_uint8(tvb, offset+5);
3895
433
  }
3896
524
  if ((sasl_length + 4) <= remaining_length) {
3897
15
      if (sasl_start[0] == 0x05 && sasl_start[1] == 0x04) {
3898
        /*
3899
         * Likely modern kerberos signing
3900
         */
3901
0
        detected_sasl_security = true;
3902
15
      } else if (sasl_start[0] == 0x60) {
3903
        /*
3904
         * Likely ASN.1 based kerberos
3905
         */
3906
1
        detected_sasl_security = true;
3907
1
      }
3908
15
  }
3909
524
  if (detected_sasl_security) {
3910
1
      ldap_info->auth_type=LDAP_AUTH_SASL;
3911
1
      ldap_info->first_auth_frame=pinfo->num;
3912
1
      ldap_info->auth_mech=wmem_strdup(wmem_file_scope(), "GSS-SPNEGO");
3913
1
      doing_sasl_security=true;
3914
1
  }
3915
3916
  /*
3917
  * This is the first PDU, set the Protocol column and clear the
3918
  * Info column.
3919
  */
3920
524
  col_set_str(pinfo->cinfo, COL_PROTOCOL, pinfo->current_proto);
3921
3922
524
  if(ldap_found_in_frame) {
3923
    /* we have already dissected an ldap PDU in this frame - add a separator and set a fence */
3924
340
    col_append_str(pinfo->cinfo, COL_INFO, " | ");
3925
340
    col_set_fence(pinfo->cinfo, COL_INFO);
3926
340
  } else {
3927
184
    col_clear(pinfo->cinfo, COL_INFO);
3928
184
    register_frame_end_routine (pinfo, ldap_frame_end);
3929
184
    ldap_found_in_frame = true;
3930
184
  }
3931
3932
524
  ldap_item = proto_tree_add_item(tree, is_mscldap?proto_cldap:proto_ldap, tvb, 0, -1, ENC_NA);
3933
524
  ldap_tree = proto_item_add_subtree(ldap_item, ett_ldap);
3934
3935
  /*
3936
  * Might we be doing a SASL security layer and, if so, *are* we doing
3937
  * one?
3938
  *
3939
  * Just because we've seen a bind reply for SASL, that doesn't mean
3940
  * that we're using a SASL security layer; I've seen captures in
3941
  * which some SASL negotiations lead to a security layer being used
3942
  * and other negotiations don't, and it's not obvious what's different
3943
  * in the two negotiations.  Therefore, we assume that if the first
3944
  * byte is 0, it's a length for a SASL security layer (that way, we
3945
  * never reassemble more than 16 megabytes, protecting us from
3946
  * chewing up *too* much memory), and otherwise that it's an LDAP
3947
  * message (actually, if it's an LDAP message it should begin with 0x30,
3948
  * but we want to parse garbage as LDAP messages rather than really
3949
  * huge lengths).
3950
  */
3951
3952
524
  if (doing_sasl_security && tvb_get_uint8(tvb, offset) == 0) {
3953
5
    proto_tree *sasl_tree;
3954
5
    tvbuff_t *sasl_tvb;
3955
5
    unsigned sasl_len, sasl_msg_len;
3956
    /*
3957
    * Yes.  The frame begins with a 4-byte big-endian length.
3958
    * And we know we have at least 6 bytes
3959
    */
3960
3961
    /*
3962
    * Get the SASL length, which is the length of data in the buffer
3963
    * following the length (i.e., it's 4 less than the total length).
3964
    *
3965
    * XXX - do we need to reassemble buffers?  For now, we
3966
    * assume that each LDAP message is entirely contained within
3967
    * a buffer.
3968
    */
3969
5
    sasl_len = tvb_get_ntohl(tvb, offset);
3970
5
    sasl_msg_len = sasl_len + 4;
3971
5
    if (sasl_msg_len < 4) {
3972
      /*
3973
      * The message length was probably so large that the total length
3974
      * overflowed.
3975
      *
3976
      * Report this as an error.
3977
      */
3978
0
      show_reported_bounds_error(tvb, pinfo, tree);
3979
0
      return;
3980
0
    }
3981
3982
    /*
3983
    * Construct a tvbuff containing the amount of the payload we have
3984
    * available.  Make its reported length the amount of data in the PDU.
3985
    */
3986
5
    sasl_tvb = tvb_new_subset_length(tvb, offset, sasl_msg_len);
3987
3988
5
    proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4, sasl_len);
3989
3990
5
    sasl_tree = proto_tree_add_subtree(ldap_tree, sasl_tvb, 4, sasl_msg_len - 4, ett_ldap_sasl_blob, NULL, "SASL Buffer");
3991
3992
5
    if (ldap_info->auth_mech != NULL &&
3993
5
      ((strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) ||
3994
      /* auth_mech may have been set from the bind */
3995
5
      (strcmp(ldap_info->auth_mech, "GSSAPI") == 0))) {
3996
5
        tvbuff_t *gssapi_tvb = NULL;
3997
5
        int ver_len;
3998
5
        gssapi_encrypt_info_t gssapi_encrypt;
3999
4000
        /*
4001
        * This is GSS-API (using SPNEGO, but we should be done with
4002
        * the negotiation by now).
4003
        *
4004
        * Dissect the GSS_Wrap() token; it'll return the length of
4005
        * the token, from which we compute the offset in the tvbuff at
4006
        * which the plaintext data, i.e. the LDAP message, begins.
4007
        */
4008
5
        gssapi_tvb = tvb_new_subset_length(sasl_tvb, 4, sasl_len);
4009
4010
        /* Attempt decryption of the GSSAPI wrapped data if possible */
4011
5
        memset(&gssapi_encrypt, 0, sizeof(gssapi_encrypt));
4012
5
        gssapi_encrypt.decrypt_gssapi_tvb=DECRYPT_GSSAPI_NORMAL;
4013
5
        ver_len = call_dissector_with_data(gssapi_wrap_handle, gssapi_tvb, pinfo, sasl_tree, &gssapi_encrypt);
4014
        /*
4015
        * If ver_len is 0, it probably means that we got a PDU that is not
4016
        * aligned to the start of the segment.
4017
        */
4018
5
        if(ver_len==0){
4019
0
          return;
4020
0
        }
4021
5
        if (gssapi_encrypt.gssapi_data_encrypted) {
4022
0
          if (gssapi_encrypt.gssapi_decrypted_tvb) {
4023
0
            tvbuff_t *decr_tvb = gssapi_encrypt.gssapi_decrypted_tvb;
4024
0
            proto_tree *enc_tree = NULL;
4025
4026
            /*
4027
             * The LDAP payload (blob) was encrypted and we were able to decrypt it.
4028
             * The data was signed via a MIC token, sealed (encrypted), and "wrapped"
4029
             * within the mechanism's "blob." Call dissect_ldap_payload to dissect
4030
             * one or more LDAPMessages such as searchRequest messages within this
4031
             * payload.
4032
             */
4033
0
            col_set_str(pinfo->cinfo, COL_INFO, "SASL GSS-API Privacy (decrypted): ");
4034
4035
0
            if (sasl_tree) {
4036
0
              unsigned decr_len = tvb_reported_length(decr_tvb);
4037
4038
0
              enc_tree = proto_tree_add_subtree_format(sasl_tree, decr_tvb, 0, -1,
4039
0
                ett_ldap_payload, NULL, "GSS-API Encrypted payload (%d byte%s)",
4040
0
                decr_len, plurality(decr_len, "", "s"));
4041
0
            }
4042
4043
0
            dissect_ldap_payload(decr_tvb, pinfo, enc_tree, ldap_info, is_mscldap);
4044
0
          } else {
4045
            /*
4046
            * The LDAP message was encrypted but couldn't be decrypted so just display the
4047
            * encrypted data all of which is found in Packet Bytes.
4048
            */
4049
0
            col_add_fstr(pinfo->cinfo, COL_INFO, "SASL GSS-API Privacy: payload (%d byte%s)",
4050
0
              sasl_len-ver_len, plurality(sasl_len-ver_len, "", "s"));
4051
4052
0
            proto_tree_add_item(sasl_tree, hf_ldap_gssapi_encrypted_payload, gssapi_tvb, ver_len, -1, ENC_NA);
4053
0
          }
4054
5
        } else {
4055
5
          tvbuff_t *plain_tvb;
4056
5
          if (gssapi_encrypt.gssapi_decrypted_tvb) {
4057
0
            plain_tvb = gssapi_encrypt.gssapi_decrypted_tvb;
4058
5
          } else {
4059
5
            plain_tvb = tvb_new_subset_remaining(gssapi_tvb, ver_len);
4060
5
          }
4061
5
          proto_tree *plain_tree = NULL;
4062
4063
          /*
4064
          * The payload was not encrypted (sealed) but was signed via a MIC token.
4065
          * If krb5_tok_id == KRB_TOKEN_CFX_WRAP, the payload was wrapped within
4066
          * the mechanism's blob. Call dissect_ldap_payload to dissect one or more
4067
          * LDAPMessages within the payload.
4068
          */
4069
5
          col_set_str(pinfo->cinfo, COL_INFO, "SASL GSS-API Integrity: ");
4070
4071
5
          if (sasl_tree) {
4072
5
            unsigned plain_len = tvb_reported_length(plain_tvb);
4073
4074
5
            plain_tree = proto_tree_add_subtree_format(sasl_tree, plain_tvb, 0, -1,
4075
5
              ett_ldap_payload, NULL, "GSS-API payload (%d byte%s)",
4076
5
              plain_len, plurality(plain_len, "", "s"));
4077
5
          }
4078
4079
5
          dissect_ldap_payload(plain_tvb, pinfo, plain_tree, ldap_info, is_mscldap);
4080
5
        }
4081
5
    }
4082
519
  } else {
4083
    /*
4084
    * The LDAP packet does not contain a SASL security layer. Such messages are typically sent
4085
    * prior to the LDAP "bind" negotiation exchange which establishes the "context" of the session.
4086
    * This means the data could neither be "signed" (no data origin auth or data integrity
4087
    * check) nor "sealed" (encrypted).
4088
    */
4089
519
    dissect_ldap_payload(tvb, pinfo, ldap_tree, ldap_info, is_mscldap);
4090
519
  }
4091
524
}
4092
4093
int dissect_mscldap_string(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, int max_len, char **str)
4094
0
{
4095
0
  int compr_len;
4096
0
  const char *name;
4097
0
  int name_len;
4098
4099
  /* The name data MUST start at offset 0 of the tvb */
4100
0
  compr_len = get_dns_name(scope, tvb, offset, max_len, 0, &name, &name_len);
4101
0
  *str = (char*)get_utf_8_string(scope, (const uint8_t*)name, name_len);
4102
0
  return offset + compr_len;
4103
0
}
4104
4105
4106
/* These are the cldap DC flags
4107
   http://msdn.microsoft.com/en-us/library/cc201036.aspx
4108
 */
4109
static const true_false_string tfs_ads_pdc = {
4110
  "This is a PDC",
4111
  "This is NOT a pdc"
4112
};
4113
static const true_false_string tfs_ads_gc = {
4114
  "This is a GLOBAL CATALOGUE of forest",
4115
  "This is NOT a global catalog of forest"
4116
};
4117
static const true_false_string tfs_ads_ldap = {
4118
  "This is an LDAP server",
4119
  "This is NOT an ldap server"
4120
};
4121
static const true_false_string tfs_ads_ds = {
4122
  "This dc supports DS",
4123
  "This dc does NOT support ds"
4124
};
4125
static const true_false_string tfs_ads_kdc = {
4126
  "This is a KDC (kerberos)",
4127
  "This is NOT a kdc (kerberos)"
4128
};
4129
static const true_false_string tfs_ads_timeserv = {
4130
  "This dc is running TIME SERVICES (ntp)",
4131
  "This dc is NOT running time services (ntp)"
4132
};
4133
static const true_false_string tfs_ads_closest = {
4134
  "This server is in the same site as the client",
4135
  "This server is NOT in the same site as the client"
4136
};
4137
static const true_false_string tfs_ads_writable = {
4138
  "This dc is WRITABLE",
4139
  "This dc is NOT writable"
4140
};
4141
static const true_false_string tfs_ads_good_timeserv = {
4142
  "This dc has a GOOD TIME SERVICE (i.e. hardware clock)",
4143
  "This dc does NOT have a good time service (i.e. no hardware clock)"
4144
};
4145
static const true_false_string tfs_ads_ndnc = {
4146
  "Domain is NON-DOMAIN NC serviced by ldap server",
4147
  "Domain is NOT non-domain nc serviced by ldap server"
4148
};
4149
static const true_false_string tfs_ads_rodc = {
4150
  "Domain controller is a Windows 2008 RODC",
4151
  "Domain controller is not a Windows 2008 RODC"
4152
};
4153
static const true_false_string tfs_ads_wdc = {
4154
  "Domain controller is a Windows 2008 writable NC",
4155
  "Domain controller is not a Windows 2008 writable NC"
4156
};
4157
static const true_false_string tfs_ads_dns = {
4158
  "Server name is in DNS format (Windows 2008)",
4159
  "Server name is not in DNS format (Windows 2008)"
4160
};
4161
static const true_false_string tfs_ads_dnc = {
4162
  "The NC is the default NC (Windows 2008)",
4163
  "The NC is not the default NC (Windows 2008)"
4164
};
4165
static const true_false_string tfs_ads_fnc = {
4166
  "The NC is the default forest NC(Windows 2008)",
4167
  "The NC is not the default forest NC (Windows 2008)"
4168
};
4169
static int dissect_mscldap_netlogon_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
4170
0
{
4171
0
  static int * const flags[] = {
4172
0
    &hf_mscldap_netlogon_flags_fnc,
4173
0
    &hf_mscldap_netlogon_flags_dnc,
4174
0
    &hf_mscldap_netlogon_flags_dns,
4175
0
    &hf_mscldap_netlogon_flags_wdc,
4176
0
    &hf_mscldap_netlogon_flags_rodc,
4177
0
    &hf_mscldap_netlogon_flags_ndnc,
4178
0
    &hf_mscldap_netlogon_flags_good_timeserv,
4179
0
    &hf_mscldap_netlogon_flags_writable,
4180
0
    &hf_mscldap_netlogon_flags_closest,
4181
0
    &hf_mscldap_netlogon_flags_timeserv,
4182
0
    &hf_mscldap_netlogon_flags_kdc,
4183
0
    &hf_mscldap_netlogon_flags_ds,
4184
0
    &hf_mscldap_netlogon_flags_ldap,
4185
0
    &hf_mscldap_netlogon_flags_gc,
4186
0
    &hf_mscldap_netlogon_flags_pdc,
4187
0
    NULL
4188
0
  };
4189
4190
0
  proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_mscldap_netlogon_flags,
4191
0
                           ett_mscldap_netlogon_flags, flags, ENC_LITTLE_ENDIAN, BMT_NO_FALSE);
4192
0
  offset += 4;
4193
4194
0
  return offset;
4195
0
}
4196
4197
static int dissect_NetLogon_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4198
0
{
4199
0
  int old_offset, offset=0;
4200
0
  char *str;
4201
0
  uint16_t itype;
4202
0
  uint16_t len;
4203
0
  uint32_t version;
4204
0
  unsigned fn_len;
4205
0
  proto_item *item;
4206
4207
0
  ldm_tree = NULL;
4208
4209
4210
  /* Get the length of the buffer */
4211
0
  len=tvb_reported_length_remaining(tvb,offset);
4212
4213
  /* check the len if it is to small return */
4214
0
  if (len < 10)
4215
0
    return tvb_captured_length(tvb);
4216
4217
  /* Type */
4218
0
  proto_tree_add_item(tree, hf_mscldap_netlogon_opcode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4219
0
  itype = tvb_get_letohs(tvb, offset);
4220
0
  offset += 2;
4221
4222
0
  switch(itype){
4223
4224
0
    case LOGON_SAM_LOGON_RESPONSE:
4225
      /* logon server name; must be aligned on a 2-byte boundary */
4226
0
      if ((offset & 1) != 0) {
4227
0
        offset++;
4228
0
      }
4229
0
      proto_tree_add_item_ret_length(tree, hf_mscldap_nb_hostname_z, tvb,offset, -1, ENC_UTF_16|ENC_LITTLE_ENDIAN, &fn_len);
4230
0
      offset +=fn_len;
4231
4232
      /* username; must be aligned on a 2-byte boundary */
4233
0
      if ((offset & 1) != 0) {
4234
0
        offset++;
4235
0
      }
4236
0
      proto_tree_add_item_ret_length(tree, hf_mscldap_username_z, tvb,offset, -1, ENC_UTF_16|ENC_LITTLE_ENDIAN, &fn_len);
4237
0
      offset +=fn_len;
4238
4239
      /* domain name; must be aligned on a 2-byte boundary */
4240
0
      if ((offset & 1) != 0) {
4241
0
        offset++;
4242
0
      }
4243
0
      proto_tree_add_item_ret_length(tree, hf_mscldap_nb_domain_z, tvb,offset, -1, ENC_UTF_16|ENC_LITTLE_ENDIAN, &fn_len);
4244
0
      offset +=fn_len;
4245
4246
      /* get the version number from the end of the buffer, as the
4247
         length is variable and the version determines what fields
4248
         need to be decoded */
4249
0
      version = tvb_get_letohl(tvb,len-8);
4250
4251
      /* include the extra version 5 fields */
4252
0
      if ((version & NETLOGON_NT_VERSION_5) == NETLOGON_NT_VERSION_5){
4253
4254
        /* domain guid */
4255
0
        proto_tree_add_item(tree, hf_mscldap_domain_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
4256
0
        offset += 16;
4257
4258
        /* domain guid part 2
4259
           there is another 16 byte guid but this is alway zero, so we will skip it */
4260
0
        offset += 16;
4261
4262
        /* Forest */
4263
0
        old_offset=offset;
4264
0
        offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4265
0
        proto_tree_add_string(tree, hf_mscldap_forest, tvb, old_offset, offset-old_offset, str);
4266
4267
        /* Domain */
4268
0
        old_offset=offset;
4269
0
        offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4270
0
        proto_tree_add_string(tree, hf_mscldap_domain, tvb, old_offset, offset-old_offset, str);
4271
4272
        /* Hostname */
4273
0
        old_offset=offset;
4274
0
        offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4275
0
        proto_tree_add_string(tree, hf_mscldap_hostname, tvb, old_offset, offset-old_offset, str);
4276
4277
        /* DC IP Address */
4278
0
        proto_tree_add_item(tree, hf_mscldap_netlogon_ipaddress, tvb, offset, 4, ENC_BIG_ENDIAN);
4279
0
        offset += 4;
4280
4281
        /* Flags */
4282
0
        dissect_mscldap_netlogon_flags(tree, tvb, offset);
4283
0
      }
4284
4285
0
      break;
4286
4287
0
    case LOGON_SAM_LOGON_RESPONSE_EX:
4288
      /* MS-ADTS 6.3.1.9 */
4289
0
      offset += 2; /* Skip over "Sbz" field (MUST be set to 0) */
4290
4291
      /* Flags */
4292
0
      offset = dissect_mscldap_netlogon_flags(tree, tvb, offset);
4293
4294
      /* Domain GUID */
4295
0
      proto_tree_add_item(tree, hf_mscldap_domain_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
4296
0
      offset += 16;
4297
4298
      /* Forest */
4299
0
      old_offset=offset;
4300
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4301
0
      proto_tree_add_string(tree, hf_mscldap_forest, tvb, old_offset, offset-old_offset, str);
4302
4303
      /* Domain */
4304
0
      old_offset=offset;
4305
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4306
0
      proto_tree_add_string(tree, hf_mscldap_domain, tvb, old_offset, offset-old_offset, str);
4307
4308
      /* Hostname */
4309
0
      old_offset=offset;
4310
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4311
0
      proto_tree_add_string(tree, hf_mscldap_hostname, tvb, old_offset, offset-old_offset, str);
4312
4313
      /* NetBIOS Domain */
4314
0
      old_offset=offset;
4315
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4316
0
      proto_tree_add_string(tree, hf_mscldap_nb_domain, tvb, old_offset, offset-old_offset, str);
4317
4318
      /* NetBIOS Hostname */
4319
0
      old_offset=offset;
4320
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4321
0
      proto_tree_add_string(tree, hf_mscldap_nb_hostname, tvb, old_offset, offset-old_offset, str);
4322
4323
      /* User */
4324
0
      old_offset=offset;
4325
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4326
0
      proto_tree_add_string(tree, hf_mscldap_username, tvb, old_offset, offset-old_offset, str);
4327
4328
      /* Server Site */
4329
0
      old_offset=offset;
4330
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4331
0
      proto_tree_add_string(tree, hf_mscldap_sitename, tvb, old_offset, offset-old_offset, str);
4332
4333
      /* Client Site */
4334
0
      old_offset=offset;
4335
0
      offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4336
0
      proto_tree_add_string(tree, hf_mscldap_clientsitename, tvb, old_offset, offset-old_offset, str);
4337
4338
      /* get the version number from the end of the buffer, as the
4339
         length is variable and the version determines what fields
4340
         need to be decoded */
4341
0
      version = tvb_get_letohl(tvb,len-8);
4342
4343
      /* include the extra fields for version 5 with IP s */
4344
0
      if ((version & NETLOGON_NT_VERSION_5EX_WITH_IP) == NETLOGON_NT_VERSION_5EX_WITH_IP){
4345
        /* The ip address is returned as a sockaddr_in structure
4346
         *
4347
         *  This section may need to be updated if the base Windows APIs
4348
         *  are changed to support ipv6, which currently is not the case.
4349
         *
4350
         *  The dissector assumes the length is based on ipv4 and
4351
         *  ignores the length
4352
         */
4353
4354
        /* skip the length of the sockaddr_in */
4355
4356
0
        offset +=1;
4357
4358
        /* add IP address and dissect the sockaddr_in structure */
4359
4360
0
        old_offset = offset + 4;
4361
0
        item = proto_tree_add_item(tree, hf_mscldap_netlogon_ipaddress, tvb, old_offset, 4, ENC_BIG_ENDIAN);
4362
4363
0
        proto_tree *subtree;
4364
4365
0
        subtree = proto_item_add_subtree(item, ett_mscldap_ipdetails);
4366
4367
        /* get sockaddr family */
4368
0
        proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_family, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4369
0
        offset +=2;
4370
4371
        /* get sockaddr port */
4372
0
        proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4373
0
        offset +=2;
4374
4375
        /* get IP address */
4376
0
        proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4377
0
        offset += 4;
4378
4379
        /* sin_zero (reserved 8 bytes, MUST be set to zero and ignored on receipt) */
4380
0
        proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_zero, tvb, offset, 8, ENC_NA);
4381
0
        offset += 8;
4382
0
      }
4383
0
      if ((version & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) == NETLOGON_NT_VERSION_WITH_CLOSEST_SITE){
4384
0
          old_offset=offset;
4385
0
          offset=dissect_mscldap_string(pinfo->pool, tvb, offset, 255, &str);
4386
0
          proto_tree_add_string(tree, hf_mscldap_nextclosestsitename, tvb, old_offset, offset-old_offset, str);
4387
0
      }
4388
4389
0
      break;
4390
0
  }
4391
4392
4393
  /* complete the decode with the version and token details */
4394
4395
0
  offset = len - 8;
4396
4397
  /* NETLOGON_NT_VERSION Options (MS-ADTS 6.3.1.1) */
4398
0
  offset = dissect_mscldap_ntver_flags(tree, tvb, offset);
4399
4400
  /* LM Token */
4401
0
  proto_tree_add_item(tree, hf_mscldap_netlogon_lm_token, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4402
0
  offset += 2;
4403
4404
  /* NT Token */
4405
0
  proto_tree_add_item(tree, hf_mscldap_netlogon_nt_token, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4406
4407
0
  return tvb_captured_length(tvb);
4408
0
}
4409
4410
4411
static unsigned
4412
get_sasl_ldap_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
4413
                      int offset, void *data _U_)
4414
0
{
4415
  /* sasl encapsulated ldap is 4 bytes plus the length in size */
4416
0
  return tvb_get_ntohl(tvb, offset)+4;
4417
0
}
4418
4419
static int
4420
dissect_sasl_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4421
0
{
4422
0
  dissect_ldap_pdu(tvb, pinfo, tree, false);
4423
0
  return tvb_captured_length(tvb);
4424
0
}
4425
4426
static unsigned
4427
get_normal_ldap_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
4428
                        int offset, void *data _U_)
4429
425
{
4430
425
  uint32_t len;
4431
425
  bool ind;
4432
425
  int data_offset;
4433
4434
  /* normal ldap is tag+len bytes plus the length
4435
   * offset is where the tag is
4436
   * offset+1 is where length starts
4437
   */
4438
425
  data_offset=get_ber_length(tvb, offset+1, &len, &ind);
4439
425
  return len+data_offset-offset;
4440
425
}
4441
4442
static int
4443
dissect_normal_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4444
403
{
4445
403
  dissect_ldap_pdu(tvb, pinfo, tree, false);
4446
403
  return tvb_captured_length(tvb);
4447
403
}
4448
4449
static int
4450
dissect_ldap_oid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
4451
0
{
4452
0
  char *oid;
4453
0
  const char *oidname;
4454
4455
  /* tvb here contains an ascii string that is really an oid */
4456
  /* XXX   we should convert the string oid into a real oid so we can use
4457
   *       proto_tree_add_oid() instead.
4458
   */
4459
4460
0
  oid=(char*)tvb_get_string_enc(pinfo->pool, tvb, 0, tvb_reported_length(tvb), ENC_UTF_8|ENC_NA);
4461
0
  if(!oid){
4462
0
    return tvb_captured_length(tvb);
4463
0
  }
4464
4465
0
  oidname=oid_resolved_from_string(pinfo->pool, oid);
4466
4467
0
  if(oidname){
4468
0
    proto_tree_add_string_format_value(tree, hf_ldap_oid, tvb, 0, tvb_reported_length(tvb), oid, "%s (%s)",oid,oidname);
4469
0
  } else {
4470
0
    proto_tree_add_string(tree, hf_ldap_oid, tvb, 0, tvb_captured_length(tvb), oid);
4471
0
  }
4472
0
  return tvb_captured_length(tvb);
4473
0
}
4474
4475
15
#define LDAP_ACCESSMASK_ADS_CREATE_CHILD    0x00000001
4476
15
#define LDAP_ACCESSMASK_ADS_DELETE_CHILD    0x00000002
4477
15
#define LDAP_ACCESSMASK_ADS_LIST            0x00000004
4478
15
#define LDAP_ACCESSMASK_ADS_SELF_WRITE      0x00000008
4479
15
#define LDAP_ACCESSMASK_ADS_READ_PROP       0x00000010
4480
15
#define LDAP_ACCESSMASK_ADS_WRITE_PROP      0x00000020
4481
15
#define LDAP_ACCESSMASK_ADS_DELETE_TREE     0x00000040
4482
15
#define LDAP_ACCESSMASK_ADS_LIST_OBJECT     0x00000080
4483
15
#define LDAP_ACCESSMASK_ADS_CONTROL_ACCESS  0x00000100
4484
4485
static void
4486
ldap_specific_rights(tvbuff_t *tvb, unsigned offset, proto_tree *tree, uint32_t access)
4487
0
{
4488
0
  static int * const access_flags[] = {
4489
0
    &hf_ldap_AccessMask_ADS_CONTROL_ACCESS,
4490
0
    &hf_ldap_AccessMask_ADS_LIST_OBJECT,
4491
0
    &hf_ldap_AccessMask_ADS_DELETE_TREE,
4492
0
    &hf_ldap_AccessMask_ADS_WRITE_PROP,
4493
0
    &hf_ldap_AccessMask_ADS_READ_PROP,
4494
0
    &hf_ldap_AccessMask_ADS_SELF_WRITE,
4495
0
    &hf_ldap_AccessMask_ADS_LIST,
4496
0
    &hf_ldap_AccessMask_ADS_DELETE_CHILD,
4497
0
    &hf_ldap_AccessMask_ADS_CREATE_CHILD,
4498
0
    NULL
4499
0
  };
4500
4501
0
  proto_tree_add_bitmask_list_value(tree, tvb, offset, 4, access_flags, access);
4502
0
}
4503
4504
static struct access_mask_info ldap_access_mask_info = {
4505
  "LDAP",                 /* Name of specific rights */
4506
  ldap_specific_rights,   /* Dissection function */
4507
  NULL,                   /* Generic mapping table */
4508
  NULL                    /* Standard mapping table */
4509
};
4510
4511
static int
4512
dissect_ldap_nt_sec_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4513
0
{
4514
0
  dissect_nt_sec_desc(tvb, 0, pinfo, tree, NULL, true, tvb_reported_length(tvb), &ldap_access_mask_info);
4515
0
  return tvb_captured_length(tvb);
4516
0
}
4517
4518
static int
4519
dissect_ldap_sid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4520
0
{
4521
0
  char *tmpstr;
4522
4523
  /* this octet string contains an NT SID */
4524
0
  dissect_nt_sid(tvb, pinfo, 0, tree, "SID", &tmpstr, hf_ldap_sid);
4525
0
  ldapvalue_string=tmpstr;
4526
0
  return tvb_captured_length(tvb);
4527
0
}
4528
4529
static int
4530
dissect_ldap_guid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4531
0
{
4532
0
  uint8_t drep[4] = { 0x10, 0x00, 0x00, 0x00}; /* fake DREP struct */
4533
0
  e_guid_t uuid;
4534
4535
  /* This octet string contained a GUID */
4536
0
  dissect_dcerpc_uuid_t(tvb, 0, pinfo, tree, drep, hf_ldap_guid, &uuid);
4537
4538
0
  ldapvalue_string=(char*)wmem_alloc(pinfo->pool, 1024);
4539
0
  snprintf(ldapvalue_string, 1023, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
4540
0
             uuid.data1, uuid.data2, uuid.data3, uuid.data4[0], uuid.data4[1],
4541
0
             uuid.data4[2], uuid.data4[3], uuid.data4[4], uuid.data4[5],
4542
0
             uuid.data4[6], uuid.data4[7]);
4543
0
  return tvb_captured_length(tvb);
4544
0
}
4545
4546
static int
4547
dissect_ldap_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
4548
69
{
4549
69
  uint32_t sasl_len;
4550
69
  uint32_t ldap_len;
4551
69
  bool ind;
4552
69
  conversation_t *conversation;
4553
69
  ldap_conv_info_t *ldap_info = NULL;
4554
4555
  /*
4556
   * Do we have a conversation for this connection?
4557
   */
4558
69
  conversation = find_conversation_pinfo(pinfo, 0);
4559
69
  if(conversation){
4560
69
    ldap_info = (ldap_conv_info_t *)conversation_get_proto_data(conversation, proto_ldap);
4561
69
  }
4562
4563
69
  ldm_tree = NULL;
4564
4565
  /* This is a bit tricky. We have to find out whether SASL is used
4566
   * so that we know how big a header we are supposed to pass
4567
   * to tcp_dissect_pdus()
4568
   * We must also cope with the case when a client connects to LDAP
4569
   * and performs a few unauthenticated searches of LDAP before
4570
   * it performs the bind on the same tcp connection.
4571
   */
4572
  /* check for a SASL header, i.e. assume it is SASL if
4573
   * 1, first four bytes (SASL length) is an integer
4574
   *    with a value that must be <LDAP_SASL_MAX_BUF and >2
4575
   *    (>2 to fight false positives, 0x00000000 is a common
4576
   *        "random" tcp payload)
4577
   * (SASL ldap PDUs might be >64k in size, which is why
4578
   * LDAP_SASL_MAX_BUF is used - defined in packet-ldap.h)
4579
   *
4580
   * 2, we must have a conversation and the auth type must
4581
   *    be LDAP_AUTH_SASL
4582
   */
4583
69
  sasl_len=tvb_get_ntohl(tvb, 0);
4584
4585
69
  if( sasl_len<2 ){
4586
1
    goto this_was_not_sasl;
4587
1
  }
4588
4589
68
  if( sasl_len>LDAP_SASL_MAX_BUF ){
4590
65
    goto this_was_not_sasl;
4591
65
  }
4592
4593
3
  if((!ldap_info) || (ldap_info->auth_type!=LDAP_AUTH_SASL) ){
4594
3
    goto this_was_not_sasl;
4595
3
  }
4596
4597
0
  tcp_dissect_pdus(tvb, pinfo, tree, ldap_desegment, 4, get_sasl_ldap_pdu_len, dissect_sasl_ldap_pdu, data);
4598
0
  return tvb_captured_length(tvb);
4599
4600
69
this_was_not_sasl:
4601
  /* check if it is a normal BER encoded LDAP packet
4602
   * i.e. first byte is 0x30 followed by a length that is
4603
   * <64k
4604
   * (no ldap PDUs are ever >64kb? )
4605
   */
4606
69
  if(tvb_get_uint8(tvb, 0)!=0x30){
4607
5
    goto this_was_not_normal_ldap;
4608
5
  }
4609
4610
  /* check that length makes sense */
4611
64
  get_ber_length(tvb, 1, &ldap_len, &ind);
4612
4613
  /* don't check ind since indefinite length is never used for ldap (famous last words)*/
4614
64
  if(ldap_len<2){
4615
1
    goto this_was_not_normal_ldap;
4616
1
  }
4617
4618
  /*
4619
   * The minimum size of a LDAP pdu is 7 bytes
4620
   *
4621
   * dumpasn1 -hh ldap-unbind-min.dat
4622
   *
4623
   *     <30 05 02 01 09 42 00>
4624
   *    0    5: SEQUENCE {
4625
   *     <02 01 09>
4626
   *    2    1:   INTEGER 9
4627
   *     <42 00>
4628
   *    5    0:   [APPLICATION 2]
4629
   *          :     Error: Object has zero length.
4630
   *          :   }
4631
   *
4632
   * dumpasn1 -hh ldap-unbind-windows.dat
4633
   *
4634
   *     <30 84 00 00 00 05 02 01 09 42 00>
4635
   *    0    5: SEQUENCE {
4636
   *     <02 01 09>
4637
   *    6    1:   INTEGER 9
4638
   *     <42 00>
4639
   *    9    0:   [APPLICATION 2]
4640
   *          :     Error: Object has zero length.
4641
   *          :   }
4642
   *
4643
   * 6 bytes would also be ok to get the full length of
4644
   * the pdu, but as the smallest pdu can be 7 bytes
4645
   * we can use 7.
4646
   */
4647
63
  tcp_dissect_pdus(tvb, pinfo, tree, ldap_desegment, 7, get_normal_ldap_pdu_len, dissect_normal_ldap_pdu, data);
4648
4649
63
  goto end;
4650
4651
6
this_was_not_normal_ldap:
4652
4653
  /* Ok it might be a strange case of SASL still
4654
   * It has been seen with Exchange setup to MS AD
4655
   * when Exchange pretend that there is SASL but in fact data are still
4656
   * in clear*/
4657
6
  if ((sasl_len + 4) == (uint32_t)tvb_reported_length_remaining(tvb, 0))
4658
0
    tcp_dissect_pdus(tvb, pinfo, tree, ldap_desegment, 4, get_sasl_ldap_pdu_len, dissect_sasl_ldap_pdu, data);
4659
33
 end:
4660
33
  return tvb_captured_length(tvb);
4661
6
}
4662
4663
static int
4664
dissect_mscldap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4665
121
{
4666
121
  dissect_ldap_pdu(tvb, pinfo, tree, true);
4667
121
  return tvb_captured_length(tvb);
4668
121
}
4669
4670
4671
/*--- proto_register_ldap -------------------------------------------*/
4672
15
void proto_register_ldap(void) {
4673
4674
  /* List of fields */
4675
4676
15
  static hf_register_info hf[] = {
4677
4678
15
    { &hf_ldap_sasl_buffer_length,
4679
15
      { "SASL Buffer Length",   "ldap.sasl_buffer_length",
4680
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
4681
15
        NULL, HFILL }},
4682
15
    { &hf_ldap_response_in,
4683
15
      { "Response In", "ldap.response_in",
4684
15
        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
4685
15
        "The response to this LDAP request is in this frame", HFILL }},
4686
15
    { &hf_ldap_response_to,
4687
15
      { "Response To", "ldap.response_to",
4688
15
        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
4689
15
        "This is a response to the LDAP request in this frame", HFILL }},
4690
15
    { &hf_ldap_time,
4691
15
      { "Time", "ldap.time",
4692
15
        FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
4693
15
        "The time between the Call and the Reply", HFILL }},
4694
4695
15
    { &hf_mscldap_netlogon_opcode,
4696
15
      { "Operation code", "mscldap.netlogon.opcode",
4697
15
        FT_UINT16, BASE_DEC, VALS(netlogon_opcode_vals), 0x0,
4698
15
        "LDAP ping operation code", HFILL }},
4699
4700
15
    { &hf_mscldap_netlogon_ipaddress_family,
4701
15
      { "Family", "mscldap.netlogon.ipaddress.family",
4702
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
4703
15
        NULL, HFILL }},
4704
4705
15
    { &hf_mscldap_netlogon_ipaddress_ipv4,
4706
15
      { "IPv4", "mscldap.netlogon.ipaddress.ipv4",
4707
15
        FT_IPv4, BASE_NONE, NULL, 0x0,
4708
15
        "IP Address", HFILL }},
4709
4710
15
    { &hf_mscldap_netlogon_ipaddress_port,
4711
15
      { "Port", "mscldap.netlogon.ipaddress.port",
4712
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
4713
15
        NULL, HFILL }},
4714
4715
15
    { &hf_mscldap_netlogon_ipaddress_zero,
4716
15
      { "Reserved", "mscldap.netlogon.ipaddress.zero",
4717
15
        FT_BYTES, BASE_NONE, NULL, 0x0,
4718
15
        "MUST be set to zero", HFILL }},
4719
4720
15
    { &hf_mscldap_netlogon_ipaddress,
4721
15
      { "IP Address","mscldap.netlogon.ipaddress",
4722
15
        FT_IPv4, BASE_NONE, NULL, 0x0,
4723
15
        "Domain Controller IP Address", HFILL }},
4724
4725
15
    { &hf_mscldap_netlogon_lm_token,
4726
15
      { "LM Token", "mscldap.netlogon.lm_token",
4727
15
        FT_UINT16, BASE_HEX, NULL, 0x0,
4728
15
        "MUST be set to 0xFFFF", HFILL }},
4729
4730
15
    { &hf_mscldap_netlogon_nt_token,
4731
15
      { "NT Token", "mscldap.netlogon.nt_token",
4732
15
        FT_UINT16, BASE_HEX, NULL, 0x0,
4733
15
        "MUST be set to 0xFFFF", HFILL }},
4734
4735
15
    { &hf_mscldap_netlogon_flags,
4736
15
      { "Flags", "mscldap.netlogon.flags",
4737
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
4738
15
        "Netlogon flags describing the DC properties", HFILL }},
4739
4740
15
    { &hf_mscldap_ntver_flags,
4741
15
      { "Version Flags", "mscldap.ntver.flags",
4742
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
4743
15
        "NETLOGON_NT_VERSION Options Bits", HFILL }},
4744
4745
15
    { &hf_mscldap_domain_guid,
4746
15
      { "Domain GUID", "mscldap.domain.guid",
4747
15
        FT_GUID, BASE_NONE, NULL, 0x0,
4748
15
        "Value of the NC's GUID attribute", HFILL }},
4749
4750
15
    { &hf_mscldap_forest,
4751
15
      { "Forest", "mscldap.forest",
4752
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4753
15
        "DNS name of the forest", HFILL }},
4754
4755
15
    { &hf_mscldap_domain,
4756
15
      { "Domain", "mscldap.domain",
4757
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4758
15
        "DNS name of the NC", HFILL }},
4759
4760
15
    { &hf_mscldap_hostname,
4761
15
      { "Hostname", "mscldap.hostname",
4762
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4763
15
        "DNS name of server", HFILL }},
4764
4765
15
    { &hf_mscldap_nb_domain_z,
4766
15
      { "NetBIOS Domain", "mscldap.nb_domain",
4767
15
        FT_STRINGZ, BASE_NONE, NULL, 0x0,
4768
15
        "NetBIOS name of the NC", HFILL }},
4769
4770
15
    { &hf_mscldap_nb_domain,
4771
15
      { "NetBIOS Domain", "mscldap.nb_domain",
4772
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4773
15
        "NetBIOS name of the NC", HFILL }},
4774
4775
15
    { &hf_mscldap_nb_hostname_z,
4776
15
      { "NetBIOS Hostname", "mscldap.nb_hostname",
4777
15
        FT_STRINGZ, BASE_NONE, NULL, 0x0,
4778
15
        "NetBIOS name of the server", HFILL }},
4779
4780
15
    { &hf_mscldap_nb_hostname,
4781
15
      { "NetBIOS Hostname", "mscldap.nb_hostname",
4782
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4783
15
        "NetBIOS name of the server", HFILL }},
4784
4785
15
    { &hf_mscldap_username_z,
4786
15
      { "Username", "mscldap.username",
4787
15
        FT_STRINGZ, BASE_NONE, NULL, 0x0,
4788
15
        "User specified in client's request", HFILL }},
4789
4790
15
    { &hf_mscldap_username,
4791
15
      { "Username", "mscldap.username",
4792
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4793
15
        "User specified in client's request", HFILL }},
4794
4795
15
    { &hf_mscldap_sitename,
4796
15
      { "Server Site", "mscldap.sitename",
4797
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4798
15
        "Site name of the server", HFILL }},
4799
4800
15
    { &hf_mscldap_clientsitename,
4801
15
      { "Client Site", "mscldap.clientsitename",
4802
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4803
15
        "Site name of the client", HFILL }},
4804
4805
15
    { &hf_mscldap_nextclosestsitename,
4806
15
      { "Next Closest Site", "mscldap.nextclosestsitename",
4807
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4808
15
        "Name of the site that is closest by cost to ClientSiteName without being equal", HFILL }},
4809
4810
15
    { &hf_ldap_sid,
4811
15
      { "Sid", "ldap.sid",
4812
15
        FT_STRING, BASE_NONE, NULL, 0x0,
4813
15
        NULL, HFILL }},
4814
4815
15
    { &hf_mscldap_ntver_flags_v1,
4816
15
      { "V1", "mscldap.ntver.searchflags.v1", FT_BOOLEAN, 32,
4817
15
        TFS(&tfs_ntver_v1), 0x00000001, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4818
4819
15
    { &hf_mscldap_ntver_flags_v5,
4820
15
      { "V5", "mscldap.ntver.searchflags.v5", FT_BOOLEAN, 32,
4821
15
        TFS(&tfs_ntver_v5), 0x00000002, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4822
4823
15
    { &hf_mscldap_ntver_flags_v5ex,
4824
15
      { "V5EX", "mscldap.ntver.searchflags.v5ex", FT_BOOLEAN, 32,
4825
15
        TFS(&tfs_ntver_v5ex), 0x00000004, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4826
4827
15
    { &hf_mscldap_ntver_flags_v5ep,
4828
15
      { "V5EP", "mscldap.ntver.searchflags.v5ep", FT_BOOLEAN, 32,
4829
15
        TFS(&tfs_ntver_v5ep), 0x00000008, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4830
4831
15
    { &hf_mscldap_ntver_flags_vcs,
4832
15
      { "VCS", "mscldap.ntver.searchflags.vcs", FT_BOOLEAN, 32,
4833
15
        TFS(&tfs_ntver_vcs), 0x00000010, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4834
4835
15
    { &hf_mscldap_ntver_flags_vnt4,
4836
15
      { "VNT4", "mscldap.ntver.searchflags.vnt4", FT_BOOLEAN, 32,
4837
15
        TFS(&tfs_ntver_vnt4), 0x01000000, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4838
4839
15
    { &hf_mscldap_ntver_flags_vpdc,
4840
15
      { "VPDC", "mscldap.ntver.searchflags.vpdc", FT_BOOLEAN, 32,
4841
15
        TFS(&tfs_ntver_vpdc), 0x10000000, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4842
4843
15
    { &hf_mscldap_ntver_flags_vip,
4844
15
      { "VIP", "mscldap.ntver.searchflags.vip", FT_BOOLEAN, 32,
4845
15
        TFS(&tfs_ntver_vip), 0x20000000, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4846
4847
15
    { &hf_mscldap_ntver_flags_vl,
4848
15
      { "VL", "mscldap.ntver.searchflags.vl", FT_BOOLEAN, 32,
4849
15
        TFS(&tfs_ntver_vl), 0x40000000, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4850
4851
15
    { &hf_mscldap_ntver_flags_vgc,
4852
15
      { "VGC", "mscldap.ntver.searchflags.vgc", FT_BOOLEAN, 32,
4853
15
        TFS(&tfs_ntver_vgc), 0x80000000, "See section 6.3.1.1 of MS-ADTS specification", HFILL }},
4854
4855
4856
15
    { &hf_mscldap_netlogon_flags_pdc,
4857
15
      { "PDC", "mscldap.netlogon.flags.pdc", FT_BOOLEAN, 32,
4858
15
        TFS(&tfs_ads_pdc), 0x00000001, "Is this DC a PDC or not?", HFILL }},
4859
4860
15
    { &hf_mscldap_netlogon_flags_gc,
4861
15
      { "GC", "mscldap.netlogon.flags.gc", FT_BOOLEAN, 32,
4862
15
        TFS(&tfs_ads_gc), 0x00000004, "Does this dc service as a GLOBAL CATALOGUE?", HFILL }},
4863
4864
15
    { &hf_mscldap_netlogon_flags_ldap,
4865
15
      { "LDAP", "mscldap.netlogon.flags.ldap", FT_BOOLEAN, 32,
4866
15
        TFS(&tfs_ads_ldap), 0x00000008, "Does this DC act as an LDAP server?", HFILL }},
4867
4868
15
    { &hf_mscldap_netlogon_flags_ds,
4869
15
      { "DS", "mscldap.netlogon.flags.ds", FT_BOOLEAN, 32,
4870
15
        TFS(&tfs_ads_ds), 0x00000010, "Does this dc provide DS services?", HFILL }},
4871
4872
15
    { &hf_mscldap_netlogon_flags_kdc,
4873
15
      { "KDC", "mscldap.netlogon.flags.kdc", FT_BOOLEAN, 32,
4874
15
        TFS(&tfs_ads_kdc), 0x00000020, "Does this dc act as a KDC?", HFILL }},
4875
4876
15
    { &hf_mscldap_netlogon_flags_timeserv,
4877
15
      { "Time Serv", "mscldap.netlogon.flags.timeserv", FT_BOOLEAN, 32,
4878
15
        TFS(&tfs_ads_timeserv), 0x00000040, "Does this dc provide time services (ntp) ?", HFILL }},
4879
4880
15
    { &hf_mscldap_netlogon_flags_closest,
4881
15
      { "Closest", "mscldap.netlogon.flags.closest", FT_BOOLEAN, 32,
4882
15
        TFS(&tfs_ads_closest), 0x00000080, "Is this the closest dc?", HFILL }},
4883
4884
15
    { &hf_mscldap_netlogon_flags_writable,
4885
15
      { "Writable", "mscldap.netlogon.flags.writable", FT_BOOLEAN, 32,
4886
15
        TFS(&tfs_ads_writable), 0x00000100, "Is this dc writable?", HFILL }},
4887
4888
15
    { &hf_mscldap_netlogon_flags_good_timeserv,
4889
15
      { "Good Time Serv", "mscldap.netlogon.flags.good_timeserv", FT_BOOLEAN, 32,
4890
15
        TFS(&tfs_ads_good_timeserv), 0x00000200, "Is this a Good Time Server? (i.e. does it have a hardware clock)", HFILL }},
4891
4892
15
    { &hf_mscldap_netlogon_flags_ndnc,
4893
15
      { "NDNC", "mscldap.netlogon.flags.ndnc", FT_BOOLEAN, 32,
4894
15
        TFS(&tfs_ads_ndnc), 0x00000400, "Is this an NDNC dc?", HFILL }},
4895
4896
15
    { &hf_mscldap_netlogon_flags_rodc,
4897
15
      { "RODC", "mscldap.netlogon.flags.rodc", FT_BOOLEAN, 32,
4898
15
        TFS(&tfs_ads_rodc), 0x00000800, "Is this an read only dc?", HFILL }},
4899
4900
15
    { &hf_mscldap_netlogon_flags_wdc,
4901
15
      { "WDC", "mscldap.netlogon.flags.writabledc", FT_BOOLEAN, 32,
4902
15
        TFS(&tfs_ads_wdc), 0x00001000, "Is this an writable dc (Windows 2008)?", HFILL }},
4903
4904
15
    { &hf_mscldap_netlogon_flags_dns,
4905
15
      { "DNS", "mscldap.netlogon.flags.dnsname", FT_BOOLEAN, 32,
4906
15
        TFS(&tfs_ads_dns), 0x20000000, "Does the server have a dns name (Windows 2008)?", HFILL }},
4907
4908
15
    { &hf_mscldap_netlogon_flags_dnc,
4909
15
      { "DNC", "mscldap.netlogon.flags.defaultnc", FT_BOOLEAN, 32,
4910
15
        TFS(&tfs_ads_dnc), 0x40000000, "Is this the default NC (Windows 2008)?", HFILL }},
4911
4912
15
    { &hf_mscldap_netlogon_flags_fnc,
4913
15
      { "FDC", "mscldap.netlogon.flags.forestnc", FT_BOOLEAN, 32,
4914
15
        TFS(&tfs_ads_fnc), 0x80000000, "Is the NC the default forest root(Windows 2008)?", HFILL }},
4915
4916
15
    { &hf_ldap_guid,
4917
15
      { "GUID", "ldap.guid", FT_GUID, BASE_NONE,
4918
15
        NULL, 0, NULL, HFILL }},
4919
4920
15
    { &hf_ldap_AccessMask_ADS_CREATE_CHILD,
4921
15
      { "Ads Create Child", "ldap.AccessMask.ADS_CREATE_CHILD", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_CREATE_CHILD, NULL, HFILL }},
4922
4923
15
    { &hf_ldap_AccessMask_ADS_DELETE_CHILD,
4924
15
      { "Ads Delete Child", "ldap.AccessMask.ADS_DELETE_CHILD", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_DELETE_CHILD, NULL, HFILL }},
4925
4926
15
    { &hf_ldap_AccessMask_ADS_LIST,
4927
15
      { "Ads List", "ldap.AccessMask.ADS_LIST", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_LIST, NULL, HFILL }},
4928
4929
15
    { &hf_ldap_AccessMask_ADS_SELF_WRITE,
4930
15
      { "Ads Self Write", "ldap.AccessMask.ADS_SELF_WRITE", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_SELF_WRITE, NULL, HFILL }},
4931
4932
15
    { &hf_ldap_AccessMask_ADS_READ_PROP,
4933
15
      { "Ads Read Prop", "ldap.AccessMask.ADS_READ_PROP", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_READ_PROP, NULL, HFILL }},
4934
4935
15
    { &hf_ldap_AccessMask_ADS_WRITE_PROP,
4936
15
      { "Ads Write Prop", "ldap.AccessMask.ADS_WRITE_PROP", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_WRITE_PROP, NULL, HFILL }},
4937
4938
15
    { &hf_ldap_AccessMask_ADS_DELETE_TREE,
4939
15
      { "Ads Delete Tree", "ldap.AccessMask.ADS_DELETE_TREE", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_DELETE_TREE, NULL, HFILL }},
4940
4941
15
    { &hf_ldap_AccessMask_ADS_LIST_OBJECT,
4942
15
      { "Ads List Object", "ldap.AccessMask.ADS_LIST_OBJECT", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_LIST_OBJECT, NULL, HFILL }},
4943
4944
15
    { &hf_ldap_AccessMask_ADS_CONTROL_ACCESS,
4945
15
      { "Ads Control Access", "ldap.AccessMask.ADS_CONTROL_ACCESS", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_CONTROL_ACCESS, NULL, HFILL }},
4946
4947
15
    { &hf_ldap_LDAPMessage_PDU,
4948
15
      { "LDAPMessage", "ldap.LDAPMessage_element", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
4949
4950
15
    { &hf_ldap_object_security_flag,
4951
15
      { "Flag Object_Security", "ldap.object_security_flag", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
4952
4953
15
    { &hf_ldap_ancestor_first_flag,
4954
15
      { "Flag Ancestor_First", "ldap.ancestor_first_flag", FT_BOOLEAN, 32, NULL, 0x00000800, NULL, HFILL }},
4955
4956
15
    { &hf_ldap_public_data_only_flag,
4957
15
      { "Flag Public_Data_Only", "ldap.public_data_only_flag", FT_BOOLEAN, 32, NULL, 0x00002000, NULL, HFILL }},
4958
4959
15
    { &hf_ldap_incremental_value_flag,
4960
15
      { "Flag Incremental_Value", "ldap.incremental_value_flag", FT_BOOLEAN, 32, NULL, 0x80000000, NULL, HFILL }},
4961
4962
15
    { &hf_ldap_oid,
4963
15
      { "OID", "ldap.oid", FT_STRING, BASE_NONE,
4964
15
        NULL, 0, NULL, HFILL }},
4965
4966
15
    { &hf_ldap_gssapi_encrypted_payload,
4967
15
      { "GSS-API Encrypted payload", "ldap.gssapi_encrypted_payload", FT_BYTES, BASE_NONE,
4968
15
        NULL, 0, NULL, HFILL }},
4969
4970
15
    { &hf_ldap_SearchControlValue_PDU,
4971
15
      { "SearchControlValue", "ldap.SearchControlValue_element",
4972
15
        FT_NONE, BASE_NONE, NULL, 0,
4973
15
        NULL, HFILL }},
4974
15
    { &hf_ldap_SortKeyList_PDU,
4975
15
      { "SortKeyList", "ldap.SortKeyList",
4976
15
        FT_UINT32, BASE_DEC, NULL, 0,
4977
15
        NULL, HFILL }},
4978
15
    { &hf_ldap_SortResult_PDU,
4979
15
      { "SortResult", "ldap.SortResult_element",
4980
15
        FT_NONE, BASE_NONE, NULL, 0,
4981
15
        NULL, HFILL }},
4982
15
    { &hf_ldap_DirSyncControlValue_PDU,
4983
15
      { "DirSyncControlValue", "ldap.DirSyncControlValue_element",
4984
15
        FT_NONE, BASE_NONE, NULL, 0,
4985
15
        NULL, HFILL }},
4986
15
    { &hf_ldap_PasswdModifyRequestValue_PDU,
4987
15
      { "PasswdModifyRequestValue", "ldap.PasswdModifyRequestValue_element",
4988
15
        FT_NONE, BASE_NONE, NULL, 0,
4989
15
        NULL, HFILL }},
4990
15
    { &hf_ldap_CancelRequestValue_PDU,
4991
15
      { "CancelRequestValue", "ldap.CancelRequestValue_element",
4992
15
        FT_NONE, BASE_NONE, NULL, 0,
4993
15
        NULL, HFILL }},
4994
15
    { &hf_ldap_SyncRequestValue_PDU,
4995
15
      { "SyncRequestValue", "ldap.SyncRequestValue_element",
4996
15
        FT_NONE, BASE_NONE, NULL, 0,
4997
15
        NULL, HFILL }},
4998
15
    { &hf_ldap_SyncStateValue_PDU,
4999
15
      { "SyncStateValue", "ldap.SyncStateValue_element",
5000
15
        FT_NONE, BASE_NONE, NULL, 0,
5001
15
        NULL, HFILL }},
5002
15
    { &hf_ldap_SyncDoneValue_PDU,
5003
15
      { "SyncDoneValue", "ldap.SyncDoneValue_element",
5004
15
        FT_NONE, BASE_NONE, NULL, 0,
5005
15
        NULL, HFILL }},
5006
15
    { &hf_ldap_SyncInfoValue_PDU,
5007
15
      { "SyncInfoValue", "ldap.SyncInfoValue",
5008
15
        FT_UINT32, BASE_DEC, VALS(ldap_SyncInfoValue_vals), 0,
5009
15
        NULL, HFILL }},
5010
15
    { &hf_ldap_PasswordPolicyResponseValue_PDU,
5011
15
      { "PasswordPolicyResponseValue", "ldap.PasswordPolicyResponseValue_element",
5012
15
        FT_NONE, BASE_NONE, NULL, 0,
5013
15
        NULL, HFILL }},
5014
15
    { &hf_ldap_messageID,
5015
15
      { "messageID", "ldap.messageID",
5016
15
        FT_UINT32, BASE_DEC, NULL, 0,
5017
15
        NULL, HFILL }},
5018
15
    { &hf_ldap_protocolOp,
5019
15
      { "protocolOp", "ldap.protocolOp",
5020
15
        FT_UINT32, BASE_DEC, VALS(ldap_ProtocolOp_vals), 0,
5021
15
        NULL, HFILL }},
5022
15
    { &hf_ldap_controls,
5023
15
      { "controls", "ldap.controls",
5024
15
        FT_UINT32, BASE_DEC, NULL, 0,
5025
15
        NULL, HFILL }},
5026
15
    { &hf_ldap_bindRequest,
5027
15
      { "bindRequest", "ldap.bindRequest_element",
5028
15
        FT_NONE, BASE_NONE, NULL, 0,
5029
15
        NULL, HFILL }},
5030
15
    { &hf_ldap_bindResponse,
5031
15
      { "bindResponse", "ldap.bindResponse_element",
5032
15
        FT_NONE, BASE_NONE, NULL, 0,
5033
15
        NULL, HFILL }},
5034
15
    { &hf_ldap_unbindRequest,
5035
15
      { "unbindRequest", "ldap.unbindRequest_element",
5036
15
        FT_NONE, BASE_NONE, NULL, 0,
5037
15
        NULL, HFILL }},
5038
15
    { &hf_ldap_searchRequest,
5039
15
      { "searchRequest", "ldap.searchRequest_element",
5040
15
        FT_NONE, BASE_NONE, NULL, 0,
5041
15
        NULL, HFILL }},
5042
15
    { &hf_ldap_searchResEntry,
5043
15
      { "searchResEntry", "ldap.searchResEntry_element",
5044
15
        FT_NONE, BASE_NONE, NULL, 0,
5045
15
        "SearchResultEntry", HFILL }},
5046
15
    { &hf_ldap_searchResDone,
5047
15
      { "searchResDone", "ldap.searchResDone_element",
5048
15
        FT_NONE, BASE_NONE, NULL, 0,
5049
15
        "SearchResultDone", HFILL }},
5050
15
    { &hf_ldap_searchResRef,
5051
15
      { "searchResRef", "ldap.searchResRef",
5052
15
        FT_UINT32, BASE_DEC, NULL, 0,
5053
15
        "SearchResultReference", HFILL }},
5054
15
    { &hf_ldap_modifyRequest,
5055
15
      { "modifyRequest", "ldap.modifyRequest_element",
5056
15
        FT_NONE, BASE_NONE, NULL, 0,
5057
15
        NULL, HFILL }},
5058
15
    { &hf_ldap_modifyResponse,
5059
15
      { "modifyResponse", "ldap.modifyResponse_element",
5060
15
        FT_NONE, BASE_NONE, NULL, 0,
5061
15
        NULL, HFILL }},
5062
15
    { &hf_ldap_addRequest,
5063
15
      { "addRequest", "ldap.addRequest_element",
5064
15
        FT_NONE, BASE_NONE, NULL, 0,
5065
15
        NULL, HFILL }},
5066
15
    { &hf_ldap_addResponse,
5067
15
      { "addResponse", "ldap.addResponse_element",
5068
15
        FT_NONE, BASE_NONE, NULL, 0,
5069
15
        NULL, HFILL }},
5070
15
    { &hf_ldap_delRequest,
5071
15
      { "delRequest", "ldap.delRequest",
5072
15
        FT_STRING, BASE_NONE, NULL, 0,
5073
15
        NULL, HFILL }},
5074
15
    { &hf_ldap_delResponse,
5075
15
      { "delResponse", "ldap.delResponse_element",
5076
15
        FT_NONE, BASE_NONE, NULL, 0,
5077
15
        NULL, HFILL }},
5078
15
    { &hf_ldap_modDNRequest,
5079
15
      { "modDNRequest", "ldap.modDNRequest_element",
5080
15
        FT_NONE, BASE_NONE, NULL, 0,
5081
15
        "ModifyDNRequest", HFILL }},
5082
15
    { &hf_ldap_modDNResponse,
5083
15
      { "modDNResponse", "ldap.modDNResponse_element",
5084
15
        FT_NONE, BASE_NONE, NULL, 0,
5085
15
        "ModifyDNResponse", HFILL }},
5086
15
    { &hf_ldap_compareRequest,
5087
15
      { "compareRequest", "ldap.compareRequest_element",
5088
15
        FT_NONE, BASE_NONE, NULL, 0,
5089
15
        NULL, HFILL }},
5090
15
    { &hf_ldap_compareResponse,
5091
15
      { "compareResponse", "ldap.compareResponse_element",
5092
15
        FT_NONE, BASE_NONE, NULL, 0,
5093
15
        NULL, HFILL }},
5094
15
    { &hf_ldap_abandonRequest,
5095
15
      { "abandonRequest", "ldap.abandonRequest",
5096
15
        FT_UINT32, BASE_DEC, NULL, 0,
5097
15
        NULL, HFILL }},
5098
15
    { &hf_ldap_extendedReq,
5099
15
      { "extendedReq", "ldap.extendedReq_element",
5100
15
        FT_NONE, BASE_NONE, NULL, 0,
5101
15
        "ExtendedRequest", HFILL }},
5102
15
    { &hf_ldap_extendedResp,
5103
15
      { "extendedResp", "ldap.extendedResp_element",
5104
15
        FT_NONE, BASE_NONE, NULL, 0,
5105
15
        "ExtendedResponse", HFILL }},
5106
15
    { &hf_ldap_intermediateResponse,
5107
15
      { "intermediateResponse", "ldap.intermediateResponse_element",
5108
15
        FT_NONE, BASE_NONE, NULL, 0,
5109
15
        NULL, HFILL }},
5110
15
    { &hf_ldap_AttributeDescriptionList_item,
5111
15
      { "AttributeDescription", "ldap.AttributeDescription",
5112
15
        FT_STRING, BASE_NONE, NULL, 0,
5113
15
        NULL, HFILL }},
5114
15
    { &hf_ldap_attributeDesc,
5115
15
      { "attributeDesc", "ldap.attributeDesc",
5116
15
        FT_STRING, BASE_NONE, NULL, 0,
5117
15
        "AttributeDescription", HFILL }},
5118
15
    { &hf_ldap_assertionValue,
5119
15
      { "assertionValue", "ldap.assertionValue",
5120
15
        FT_STRING, BASE_NONE, NULL, 0,
5121
15
        NULL, HFILL }},
5122
15
    { &hf_ldap_type,
5123
15
      { "type", "ldap.type",
5124
15
        FT_STRING, BASE_NONE, NULL, 0,
5125
15
        "AttributeDescription", HFILL }},
5126
15
    { &hf_ldap_vals,
5127
15
      { "vals", "ldap.vals",
5128
15
        FT_UINT32, BASE_DEC, NULL, 0,
5129
15
        "SET_OF_AttributeValue", HFILL }},
5130
15
    { &hf_ldap_vals_item,
5131
15
      { "AttributeValue", "ldap.AttributeValue",
5132
15
        FT_BYTES, BASE_NONE, NULL, 0,
5133
15
        NULL, HFILL }},
5134
15
    { &hf_ldap_resultCode,
5135
15
      { "resultCode", "ldap.resultCode",
5136
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_resultCode_vals), 0,
5137
15
        NULL, HFILL }},
5138
15
    { &hf_ldap_matchedDN,
5139
15
      { "matchedDN", "ldap.matchedDN",
5140
15
        FT_STRING, BASE_NONE, NULL, 0,
5141
15
        "LDAPDN", HFILL }},
5142
15
    { &hf_ldap_errorMessage,
5143
15
      { "errorMessage", "ldap.errorMessage",
5144
15
        FT_STRING, BASE_NONE, NULL, 0,
5145
15
        NULL, HFILL }},
5146
15
    { &hf_ldap_referral,
5147
15
      { "referral", "ldap.referral",
5148
15
        FT_UINT32, BASE_DEC, NULL, 0,
5149
15
        NULL, HFILL }},
5150
15
    { &hf_ldap_Referral_item,
5151
15
      { "LDAPURL", "ldap.LDAPURL",
5152
15
        FT_STRING, BASE_NONE, NULL, 0,
5153
15
        NULL, HFILL }},
5154
15
    { &hf_ldap_Controls_item,
5155
15
      { "Control", "ldap.Control_element",
5156
15
        FT_NONE, BASE_NONE, NULL, 0,
5157
15
        NULL, HFILL }},
5158
15
    { &hf_ldap_controlType,
5159
15
      { "controlType", "ldap.controlType",
5160
15
        FT_STRING, BASE_NONE, NULL, 0,
5161
15
        NULL, HFILL }},
5162
15
    { &hf_ldap_criticality,
5163
15
      { "criticality", "ldap.criticality",
5164
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5165
15
        "BOOLEAN", HFILL }},
5166
15
    { &hf_ldap_controlValue,
5167
15
      { "controlValue", "ldap.controlValue",
5168
15
        FT_BYTES, BASE_NONE, NULL, 0,
5169
15
        NULL, HFILL }},
5170
15
    { &hf_ldap_version,
5171
15
      { "version", "ldap.version",
5172
15
        FT_UINT32, BASE_DEC, NULL, 0,
5173
15
        "INTEGER_1_127", HFILL }},
5174
15
    { &hf_ldap_name,
5175
15
      { "name", "ldap.name",
5176
15
        FT_STRING, BASE_NONE, NULL, 0,
5177
15
        "LDAPDN", HFILL }},
5178
15
    { &hf_ldap_authentication,
5179
15
      { "authentication", "ldap.authentication",
5180
15
        FT_UINT32, BASE_DEC, VALS(ldap_AuthenticationChoice_vals), 0,
5181
15
        "AuthenticationChoice", HFILL }},
5182
15
    { &hf_ldap_simple,
5183
15
      { "simple", "ldap.simple",
5184
15
        FT_STRING, BASE_NONE, NULL, 0,
5185
15
        NULL, HFILL }},
5186
15
    { &hf_ldap_sasl,
5187
15
      { "sasl", "ldap.sasl_element",
5188
15
        FT_NONE, BASE_NONE, NULL, 0,
5189
15
        "SaslCredentials", HFILL }},
5190
15
    { &hf_ldap_ntlmsspNegotiate,
5191
15
      { "ntlmsspNegotiate", "ldap.ntlmsspNegotiate",
5192
15
        FT_BYTES, BASE_NONE, NULL, 0,
5193
15
        NULL, HFILL }},
5194
15
    { &hf_ldap_ntlmsspAuth,
5195
15
      { "ntlmsspAuth", "ldap.ntlmsspAuth",
5196
15
        FT_BYTES, BASE_NONE, NULL, 0,
5197
15
        NULL, HFILL }},
5198
15
    { &hf_ldap_mechanism,
5199
15
      { "mechanism", "ldap.mechanism",
5200
15
        FT_STRING, BASE_NONE, NULL, 0,
5201
15
        NULL, HFILL }},
5202
15
    { &hf_ldap_credentials,
5203
15
      { "credentials", "ldap.credentials",
5204
15
        FT_BYTES, BASE_NONE, NULL, 0,
5205
15
        NULL, HFILL }},
5206
15
    { &hf_ldap_bindResponse_resultCode,
5207
15
      { "resultCode", "ldap.bindResponse_resultCode",
5208
15
        FT_UINT32, BASE_DEC, VALS(ldap_BindResponse_resultCode_vals), 0,
5209
15
        "BindResponse_resultCode", HFILL }},
5210
15
    { &hf_ldap_bindResponse_matchedDN,
5211
15
      { "matchedDN", "ldap.bindResponse_matchedDN",
5212
15
        FT_STRING, BASE_NONE, NULL, 0,
5213
15
        "T_bindResponse_matchedDN", HFILL }},
5214
15
    { &hf_ldap_serverSaslCreds,
5215
15
      { "serverSaslCreds", "ldap.serverSaslCreds",
5216
15
        FT_BYTES, BASE_NONE, NULL, 0,
5217
15
        NULL, HFILL }},
5218
15
    { &hf_ldap_baseObject,
5219
15
      { "baseObject", "ldap.baseObject",
5220
15
        FT_STRING, BASE_NONE, NULL, 0,
5221
15
        "LDAPDN", HFILL }},
5222
15
    { &hf_ldap_scope,
5223
15
      { "scope", "ldap.scope",
5224
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_scope_vals), 0,
5225
15
        NULL, HFILL }},
5226
15
    { &hf_ldap_derefAliases,
5227
15
      { "derefAliases", "ldap.derefAliases",
5228
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_derefAliases_vals), 0,
5229
15
        NULL, HFILL }},
5230
15
    { &hf_ldap_sizeLimit,
5231
15
      { "sizeLimit", "ldap.sizeLimit",
5232
15
        FT_UINT32, BASE_DEC, NULL, 0,
5233
15
        "INTEGER_0_maxInt", HFILL }},
5234
15
    { &hf_ldap_timeLimit,
5235
15
      { "timeLimit", "ldap.timeLimit",
5236
15
        FT_UINT32, BASE_DEC, NULL, 0,
5237
15
        "INTEGER_0_maxInt", HFILL }},
5238
15
    { &hf_ldap_typesOnly,
5239
15
      { "typesOnly", "ldap.typesOnly",
5240
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5241
15
        "BOOLEAN", HFILL }},
5242
15
    { &hf_ldap_filter,
5243
15
      { "filter", "ldap.filter",
5244
15
        FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5245
15
        NULL, HFILL }},
5246
15
    { &hf_ldap_searchRequest_attributes,
5247
15
      { "attributes", "ldap.searchRequest_attributes",
5248
15
        FT_UINT32, BASE_DEC, NULL, 0,
5249
15
        "AttributeDescriptionList", HFILL }},
5250
15
    { &hf_ldap_and,
5251
15
      { "and", "ldap.and",
5252
15
        FT_UINT32, BASE_DEC, NULL, 0,
5253
15
        NULL, HFILL }},
5254
15
    { &hf_ldap_and_item,
5255
15
      { "and item", "ldap.and_item",
5256
15
        FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5257
15
        NULL, HFILL }},
5258
15
    { &hf_ldap_or,
5259
15
      { "or", "ldap.or",
5260
15
        FT_UINT32, BASE_DEC, NULL, 0,
5261
15
        NULL, HFILL }},
5262
15
    { &hf_ldap_or_item,
5263
15
      { "or item", "ldap.or_item",
5264
15
        FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5265
15
        NULL, HFILL }},
5266
15
    { &hf_ldap_not,
5267
15
      { "not", "ldap.not",
5268
15
        FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5269
15
        NULL, HFILL }},
5270
15
    { &hf_ldap_equalityMatch,
5271
15
      { "equalityMatch", "ldap.equalityMatch_element",
5272
15
        FT_NONE, BASE_NONE, NULL, 0,
5273
15
        NULL, HFILL }},
5274
15
    { &hf_ldap_substrings,
5275
15
      { "substrings", "ldap.substrings_element",
5276
15
        FT_NONE, BASE_NONE, NULL, 0,
5277
15
        "SubstringFilter", HFILL }},
5278
15
    { &hf_ldap_greaterOrEqual,
5279
15
      { "greaterOrEqual", "ldap.greaterOrEqual_element",
5280
15
        FT_NONE, BASE_NONE, NULL, 0,
5281
15
        NULL, HFILL }},
5282
15
    { &hf_ldap_lessOrEqual,
5283
15
      { "lessOrEqual", "ldap.lessOrEqual_element",
5284
15
        FT_NONE, BASE_NONE, NULL, 0,
5285
15
        NULL, HFILL }},
5286
15
    { &hf_ldap_present,
5287
15
      { "present", "ldap.present",
5288
15
        FT_STRING, BASE_NONE, NULL, 0,
5289
15
        NULL, HFILL }},
5290
15
    { &hf_ldap_approxMatch,
5291
15
      { "approxMatch", "ldap.approxMatch_element",
5292
15
        FT_NONE, BASE_NONE, NULL, 0,
5293
15
        NULL, HFILL }},
5294
15
    { &hf_ldap_extensibleMatch,
5295
15
      { "extensibleMatch", "ldap.extensibleMatch_element",
5296
15
        FT_NONE, BASE_NONE, NULL, 0,
5297
15
        NULL, HFILL }},
5298
15
    { &hf_ldap_substringFilter_substrings,
5299
15
      { "substrings", "ldap.substringFilter_substrings",
5300
15
        FT_UINT32, BASE_DEC, NULL, 0,
5301
15
        "T_substringFilter_substrings", HFILL }},
5302
15
    { &hf_ldap_substringFilter_substrings_item,
5303
15
      { "substrings item", "ldap.substringFilter_substrings_item",
5304
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_substringFilter_substrings_item_vals), 0,
5305
15
        "T_substringFilter_substrings_item", HFILL }},
5306
15
    { &hf_ldap_initial,
5307
15
      { "initial", "ldap.initial",
5308
15
        FT_STRING, BASE_NONE, NULL, 0,
5309
15
        "LDAPString", HFILL }},
5310
15
    { &hf_ldap_any,
5311
15
      { "any", "ldap.any",
5312
15
        FT_STRING, BASE_NONE, NULL, 0,
5313
15
        "LDAPString", HFILL }},
5314
15
    { &hf_ldap_final,
5315
15
      { "final", "ldap.final",
5316
15
        FT_STRING, BASE_NONE, NULL, 0,
5317
15
        "LDAPString", HFILL }},
5318
15
    { &hf_ldap_matchingRule,
5319
15
      { "matchingRule", "ldap.matchingRule",
5320
15
        FT_STRING, BASE_NONE, NULL, 0,
5321
15
        "MatchingRuleId", HFILL }},
5322
15
    { &hf_ldap_matchValue,
5323
15
      { "matchValue", "ldap.matchValue",
5324
15
        FT_STRING, BASE_NONE, NULL, 0,
5325
15
        "AssertionValue", HFILL }},
5326
15
    { &hf_ldap_dnAttributes,
5327
15
      { "dnAttributes", "ldap.dnAttributes",
5328
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5329
15
        NULL, HFILL }},
5330
15
    { &hf_ldap_objectName,
5331
15
      { "objectName", "ldap.objectName",
5332
15
        FT_STRING, BASE_NONE, NULL, 0,
5333
15
        "LDAPDN", HFILL }},
5334
15
    { &hf_ldap_searchResultEntry_attributes,
5335
15
      { "attributes", "ldap.searchResultEntry_attributes",
5336
15
        FT_UINT32, BASE_DEC, NULL, 0,
5337
15
        "PartialAttributeList", HFILL }},
5338
15
    { &hf_ldap_PartialAttributeList_item,
5339
15
      { "PartialAttributeList item", "ldap.PartialAttributeList_item_element",
5340
15
        FT_NONE, BASE_NONE, NULL, 0,
5341
15
        NULL, HFILL }},
5342
15
    { &hf_ldap__untag_item,
5343
15
      { "LDAPURL", "ldap.LDAPURL",
5344
15
        FT_STRING, BASE_NONE, NULL, 0,
5345
15
        NULL, HFILL }},
5346
15
    { &hf_ldap_object,
5347
15
      { "object", "ldap.object",
5348
15
        FT_STRING, BASE_NONE, NULL, 0,
5349
15
        "LDAPDN", HFILL }},
5350
15
    { &hf_ldap_modifyRequest_modification,
5351
15
      { "modification", "ldap.modifyRequest_modification",
5352
15
        FT_UINT32, BASE_DEC, NULL, 0,
5353
15
        "ModifyRequest_modification", HFILL }},
5354
15
    { &hf_ldap_modifyRequest_modification_item,
5355
15
      { "modification item", "ldap.modifyRequest_modification_item_element",
5356
15
        FT_NONE, BASE_NONE, NULL, 0,
5357
15
        "T_modifyRequest_modification_item", HFILL }},
5358
15
    { &hf_ldap_operation,
5359
15
      { "operation", "ldap.operation",
5360
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_operation_vals), 0,
5361
15
        NULL, HFILL }},
5362
15
    { &hf_ldap_modification,
5363
15
      { "modification", "ldap.modification_element",
5364
15
        FT_NONE, BASE_NONE, NULL, 0,
5365
15
        "AttributeTypeAndValues", HFILL }},
5366
15
    { &hf_ldap_entry,
5367
15
      { "entry", "ldap.entry",
5368
15
        FT_STRING, BASE_NONE, NULL, 0,
5369
15
        "LDAPDN", HFILL }},
5370
15
    { &hf_ldap_attributes,
5371
15
      { "attributes", "ldap.attributes",
5372
15
        FT_UINT32, BASE_DEC, NULL, 0,
5373
15
        "AttributeList", HFILL }},
5374
15
    { &hf_ldap_AttributeList_item,
5375
15
      { "AttributeList item", "ldap.AttributeList_item_element",
5376
15
        FT_NONE, BASE_NONE, NULL, 0,
5377
15
        NULL, HFILL }},
5378
15
    { &hf_ldap_newrdn,
5379
15
      { "newrdn", "ldap.newrdn",
5380
15
        FT_STRING, BASE_NONE, NULL, 0,
5381
15
        "RelativeLDAPDN", HFILL }},
5382
15
    { &hf_ldap_deleteoldrdn,
5383
15
      { "deleteoldrdn", "ldap.deleteoldrdn",
5384
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5385
15
        "BOOLEAN", HFILL }},
5386
15
    { &hf_ldap_newSuperior,
5387
15
      { "newSuperior", "ldap.newSuperior",
5388
15
        FT_STRING, BASE_NONE, NULL, 0,
5389
15
        "LDAPDN", HFILL }},
5390
15
    { &hf_ldap_ava,
5391
15
      { "ava", "ldap.ava_element",
5392
15
        FT_NONE, BASE_NONE, NULL, 0,
5393
15
        "AttributeValueAssertion", HFILL }},
5394
15
    { &hf_ldap_requestName,
5395
15
      { "requestName", "ldap.requestName",
5396
15
        FT_STRING, BASE_NONE, NULL, 0,
5397
15
        "LDAPOID", HFILL }},
5398
15
    { &hf_ldap_requestValue,
5399
15
      { "requestValue", "ldap.requestValue",
5400
15
        FT_BYTES, BASE_NONE, NULL, 0,
5401
15
        NULL, HFILL }},
5402
15
    { &hf_ldap_extendedResponse_resultCode,
5403
15
      { "resultCode", "ldap.extendedResponse_resultCode",
5404
15
        FT_UINT32, BASE_DEC, VALS(ldap_ExtendedResponse_resultCode_vals), 0,
5405
15
        "ExtendedResponse_resultCode", HFILL }},
5406
15
    { &hf_ldap_responseName,
5407
15
      { "responseName", "ldap.responseName",
5408
15
        FT_STRING, BASE_NONE, NULL, 0,
5409
15
        NULL, HFILL }},
5410
15
    { &hf_ldap_response,
5411
15
      { "response", "ldap.response",
5412
15
        FT_BYTES, BASE_NONE, NULL, 0,
5413
15
        "OCTET_STRING", HFILL }},
5414
15
    { &hf_ldap_intermediateResponse_responseValue,
5415
15
      { "responseValue", "ldap.intermediateResponse_responseValue",
5416
15
        FT_BYTES, BASE_NONE, NULL, 0,
5417
15
        "T_intermediateResponse_responseValue", HFILL }},
5418
15
    { &hf_ldap_size,
5419
15
      { "size", "ldap.size",
5420
15
        FT_INT32, BASE_DEC, NULL, 0,
5421
15
        "INTEGER", HFILL }},
5422
15
    { &hf_ldap_cookie,
5423
15
      { "cookie", "ldap.cookie",
5424
15
        FT_BYTES, BASE_NONE, NULL, 0,
5425
15
        "OCTET_STRING", HFILL }},
5426
15
    { &hf_ldap_SortKeyList_item,
5427
15
      { "SortKeyList item", "ldap.SortKeyList_item_element",
5428
15
        FT_NONE, BASE_NONE, NULL, 0,
5429
15
        NULL, HFILL }},
5430
15
    { &hf_ldap_attributeType,
5431
15
      { "attributeType", "ldap.attributeType",
5432
15
        FT_STRING, BASE_NONE, NULL, 0,
5433
15
        "AttributeDescription", HFILL }},
5434
15
    { &hf_ldap_orderingRule,
5435
15
      { "orderingRule", "ldap.orderingRule",
5436
15
        FT_STRING, BASE_NONE, NULL, 0,
5437
15
        "MatchingRuleId", HFILL }},
5438
15
    { &hf_ldap_reverseOrder,
5439
15
      { "reverseOrder", "ldap.reverseOrder",
5440
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5441
15
        "BOOLEAN", HFILL }},
5442
15
    { &hf_ldap_sortResult,
5443
15
      { "sortResult", "ldap.sortResult",
5444
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_sortResult_vals), 0,
5445
15
        NULL, HFILL }},
5446
15
    { &hf_ldap_flags,
5447
15
      { "flags", "ldap.flags",
5448
15
        FT_UINT32, BASE_HEX, NULL, 0,
5449
15
        "DirSyncFlags", HFILL }},
5450
15
    { &hf_ldap_maxBytes,
5451
15
      { "maxBytes", "ldap.maxBytes",
5452
15
        FT_INT32, BASE_DEC, NULL, 0,
5453
15
        "INTEGER", HFILL }},
5454
15
    { &hf_ldap_userIdentity,
5455
15
      { "userIdentity", "ldap.userIdentity",
5456
15
        FT_BYTES, BASE_NONE, NULL, 0,
5457
15
        "OCTET_STRING", HFILL }},
5458
15
    { &hf_ldap_oldPasswd,
5459
15
      { "oldPasswd", "ldap.oldPasswd",
5460
15
        FT_BYTES, BASE_NONE, NULL, 0,
5461
15
        "OCTET_STRING", HFILL }},
5462
15
    { &hf_ldap_newPasswd,
5463
15
      { "newPasswd", "ldap.newPasswd",
5464
15
        FT_BYTES, BASE_NONE, NULL, 0,
5465
15
        "OCTET_STRING", HFILL }},
5466
15
    { &hf_ldap_cancelID,
5467
15
      { "cancelID", "ldap.cancelID",
5468
15
        FT_UINT32, BASE_DEC, NULL, 0,
5469
15
        "MessageID", HFILL }},
5470
15
    { &hf_ldap_mode,
5471
15
      { "mode", "ldap.mode",
5472
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_mode_vals), 0,
5473
15
        NULL, HFILL }},
5474
15
    { &hf_ldap_reloadHint,
5475
15
      { "reloadHint", "ldap.reloadHint",
5476
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5477
15
        "BOOLEAN", HFILL }},
5478
15
    { &hf_ldap_state,
5479
15
      { "state", "ldap.state",
5480
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_state_vals), 0,
5481
15
        NULL, HFILL }},
5482
15
    { &hf_ldap_entryUUID,
5483
15
      { "entryUUID", "ldap.entryUUID",
5484
15
        FT_BYTES, BASE_NONE, NULL, 0,
5485
15
        "SyncUUID", HFILL }},
5486
15
    { &hf_ldap_refreshDeletes,
5487
15
      { "refreshDeletes", "ldap.refreshDeletes",
5488
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5489
15
        "BOOLEAN", HFILL }},
5490
15
    { &hf_ldap_newcookie,
5491
15
      { "newcookie", "ldap.newcookie",
5492
15
        FT_BYTES, BASE_NONE, NULL, 0,
5493
15
        "OCTET_STRING", HFILL }},
5494
15
    { &hf_ldap_refreshDelete,
5495
15
      { "refreshDelete", "ldap.refreshDelete_element",
5496
15
        FT_NONE, BASE_NONE, NULL, 0,
5497
15
        NULL, HFILL }},
5498
15
    { &hf_ldap_refreshDone,
5499
15
      { "refreshDone", "ldap.refreshDone",
5500
15
        FT_BOOLEAN, BASE_NONE, NULL, 0,
5501
15
        "BOOLEAN", HFILL }},
5502
15
    { &hf_ldap_refreshPresent,
5503
15
      { "refreshPresent", "ldap.refreshPresent_element",
5504
15
        FT_NONE, BASE_NONE, NULL, 0,
5505
15
        NULL, HFILL }},
5506
15
    { &hf_ldap_syncIdSet,
5507
15
      { "syncIdSet", "ldap.syncIdSet_element",
5508
15
        FT_NONE, BASE_NONE, NULL, 0,
5509
15
        NULL, HFILL }},
5510
15
    { &hf_ldap_syncUUIDs,
5511
15
      { "syncUUIDs", "ldap.syncUUIDs",
5512
15
        FT_UINT32, BASE_DEC, NULL, 0,
5513
15
        "SET_OF_SyncUUID", HFILL }},
5514
15
    { &hf_ldap_syncUUIDs_item,
5515
15
      { "SyncUUID", "ldap.SyncUUID",
5516
15
        FT_BYTES, BASE_NONE, NULL, 0,
5517
15
        NULL, HFILL }},
5518
15
    { &hf_ldap_warning,
5519
15
      { "warning", "ldap.warning",
5520
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_warning_vals), 0,
5521
15
        NULL, HFILL }},
5522
15
    { &hf_ldap_timeBeforeExpiration,
5523
15
      { "timeBeforeExpiration", "ldap.timeBeforeExpiration",
5524
15
        FT_UINT32, BASE_DEC, NULL, 0,
5525
15
        "INTEGER_0_maxInt", HFILL }},
5526
15
    { &hf_ldap_graceAuthNsRemaining,
5527
15
      { "graceAuthNsRemaining", "ldap.graceAuthNsRemaining",
5528
15
        FT_UINT32, BASE_DEC, NULL, 0,
5529
15
        "INTEGER_0_maxInt", HFILL }},
5530
15
    { &hf_ldap_error,
5531
15
      { "error", "ldap.error",
5532
15
        FT_UINT32, BASE_DEC, VALS(ldap_T_error_vals), 0,
5533
15
        NULL, HFILL }},
5534
15
  };
5535
5536
  /* List of subtrees */
5537
15
  static int *ett[] = {
5538
15
    &ett_ldap,
5539
15
    &ett_ldap_payload,
5540
15
    &ett_ldap_sasl_blob,
5541
15
    &ett_ldap_msg,
5542
15
    &ett_mscldap_netlogon_flags,
5543
15
    &ett_mscldap_ntver_flags,
5544
15
    &ett_mscldap_ipdetails,
5545
15
    &ett_ldap_DirSyncFlagsSubEntry,
5546
5547
15
    &ett_ldap_LDAPMessage,
5548
15
    &ett_ldap_ProtocolOp,
5549
15
    &ett_ldap_AttributeDescriptionList,
5550
15
    &ett_ldap_AttributeValueAssertion,
5551
15
    &ett_ldap_Attribute,
5552
15
    &ett_ldap_SET_OF_AttributeValue,
5553
15
    &ett_ldap_LDAPResult,
5554
15
    &ett_ldap_Referral,
5555
15
    &ett_ldap_Controls,
5556
15
    &ett_ldap_Control,
5557
15
    &ett_ldap_BindRequest_U,
5558
15
    &ett_ldap_AuthenticationChoice,
5559
15
    &ett_ldap_SaslCredentials,
5560
15
    &ett_ldap_BindResponse_U,
5561
15
    &ett_ldap_SearchRequest_U,
5562
15
    &ett_ldap_Filter,
5563
15
    &ett_ldap_T_and,
5564
15
    &ett_ldap_T_or,
5565
15
    &ett_ldap_SubstringFilter,
5566
15
    &ett_ldap_T_substringFilter_substrings,
5567
15
    &ett_ldap_T_substringFilter_substrings_item,
5568
15
    &ett_ldap_MatchingRuleAssertion,
5569
15
    &ett_ldap_SearchResultEntry_U,
5570
15
    &ett_ldap_PartialAttributeList,
5571
15
    &ett_ldap_PartialAttributeList_item,
5572
15
    &ett_ldap_SEQUENCE_OF_LDAPURL,
5573
15
    &ett_ldap_ModifyRequest_U,
5574
15
    &ett_ldap_ModifyRequest_modification,
5575
15
    &ett_ldap_T_modifyRequest_modification_item,
5576
15
    &ett_ldap_AttributeTypeAndValues,
5577
15
    &ett_ldap_AddRequest_U,
5578
15
    &ett_ldap_AttributeList,
5579
15
    &ett_ldap_AttributeList_item,
5580
15
    &ett_ldap_ModifyDNRequest_U,
5581
15
    &ett_ldap_CompareRequest_U,
5582
15
    &ett_ldap_ExtendedRequest_U,
5583
15
    &ett_ldap_ExtendedResponse_U,
5584
15
    &ett_ldap_IntermediateResponse_U,
5585
15
    &ett_ldap_SearchControlValue,
5586
15
    &ett_ldap_SortKeyList,
5587
15
    &ett_ldap_SortKeyList_item,
5588
15
    &ett_ldap_SortResult,
5589
15
    &ett_ldap_DirSyncControlValue,
5590
15
    &ett_ldap_PasswdModifyRequestValue,
5591
15
    &ett_ldap_CancelRequestValue,
5592
15
    &ett_ldap_SyncRequestValue,
5593
15
    &ett_ldap_SyncStateValue,
5594
15
    &ett_ldap_SyncDoneValue,
5595
15
    &ett_ldap_SyncInfoValue,
5596
15
    &ett_ldap_T_refreshDelete,
5597
15
    &ett_ldap_T_refreshPresent,
5598
15
    &ett_ldap_T_syncIdSet,
5599
15
    &ett_ldap_SET_OF_SyncUUID,
5600
15
    &ett_ldap_PasswordPolicyResponseValue,
5601
15
    &ett_ldap_T_warning,
5602
15
  };
5603
  /* UAT for header fields */
5604
15
  static uat_field_t custom_attribute_types_uat_fields[] = {
5605
15
     UAT_FLD_CSTRING(attribute_types, attribute_type, "Attribute type", "Attribute type"),
5606
15
     UAT_FLD_CSTRING(attribute_types, attribute_desc, "Description", "Description of the value matching type"),
5607
15
     UAT_END_FIELDS
5608
15
  };
5609
5610
15
  static ei_register_info ei[] = {
5611
15
     { &ei_ldap_exceeded_filter_length, { "ldap.exceeded_filter_length", PI_UNDECODED, PI_ERROR, "Filter length exceeds number. Giving up", EXPFILL }},
5612
15
     { &ei_ldap_too_many_filter_elements, { "ldap.too_many_filter_elements", PI_UNDECODED, PI_ERROR, "Found too many filter elements. Giving up.", EXPFILL }},
5613
15
  };
5614
5615
15
  expert_module_t* expert_ldap;
5616
15
  module_t *ldap_module;
5617
15
  uat_t *attributes_uat;
5618
5619
  /* Register protocol */
5620
15
  proto_ldap = proto_register_protocol("Lightweight Directory Access Protocol", "LDAP", "ldap");
5621
  /* Register fields and subtrees */
5622
15
  proto_register_field_array(proto_ldap, hf, array_length(hf));
5623
15
  proto_register_subtree_array(ett, array_length(ett));
5624
15
  expert_ldap = expert_register_protocol(proto_ldap);
5625
15
  expert_register_field_array(expert_ldap, ei, array_length(ei));
5626
5627
15
  ldap_handle = register_dissector("ldap", dissect_ldap_tcp, proto_ldap);
5628
5629
15
  ldap_module = prefs_register_protocol(proto_ldap, prefs_register_ldap);
5630
15
  prefs_register_bool_preference(ldap_module, "desegment_ldap_messages",
5631
15
    "Reassemble LDAP messages spanning multiple TCP segments",
5632
15
    "Whether the LDAP dissector should reassemble messages spanning multiple TCP segments."
5633
15
    " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
5634
15
    &ldap_desegment);
5635
5636
15
  prefs_register_uint_preference(ldap_module, "tls.port", "LDAPS TCP Port",
5637
15
                                 "Set the port for LDAP operations over TLS",
5638
15
                                 10, &global_ldaps_tcp_port);
5639
15
  prefs_register_obsolete_preference(ldap_module, "ssl.port");
5640
  /* UAT */
5641
15
  attributes_uat = uat_new("Custom LDAP AttributeValue types",
5642
15
                           sizeof(attribute_type_t),
5643
15
                           "custom_ldap_attribute_types",
5644
15
                           true,
5645
15
                           &attribute_types,
5646
15
                           &num_attribute_types,
5647
                           /* specifies named fields, so affects dissection
5648
                              and the set of named fields */
5649
15
                           UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
5650
15
                           NULL,
5651
15
                           attribute_types_copy_cb,
5652
15
                           attribute_types_update_cb,
5653
15
                           attribute_types_free_cb,
5654
15
                           attribute_types_post_update_cb,
5655
15
                           attribute_types_reset_cb,
5656
15
                           custom_attribute_types_uat_fields);
5657
5658
15
  prefs_register_uat_preference(ldap_module, "custom_ldap_attribute_types",
5659
15
                                "Custom AttributeValue types",
5660
15
                                "A table to define custom LDAP attribute type values for which fields can be setup and used for filtering/data extraction etc.",
5661
15
                                attributes_uat);
5662
5663
15
  prefs_register_obsolete_preference(ldap_module, "max_pdu");
5664
5665
15
  proto_cldap = proto_register_protocol("Connectionless Lightweight Directory Access Protocol", "CLDAP", "cldap");
5666
15
  cldap_handle = register_dissector("cldap", dissect_mscldap, proto_cldap);
5667
5668
15
  ldap_tap=register_tap("ldap");
5669
5670
15
  ldap_name_dissector_table = register_dissector_table("ldap.name", "LDAP Attribute Type Dissectors", proto_cldap, FT_STRING, STRING_CASE_INSENSITIVE);
5671
5672
15
  register_srt_table(proto_ldap, NULL, 1, ldapstat_packet, ldapstat_init, NULL);
5673
15
}
5674
5675
5676
/*--- proto_reg_handoff_ldap ---------------------------------------*/
5677
void
5678
proto_reg_handoff_ldap(void)
5679
15
{
5680
15
  dissector_handle_t ldap_sid_handle = NULL;
5681
5682
15
  dissector_add_uint_with_preference("udp.port", UDP_PORT_CLDAP, cldap_handle);
5683
5684
15
  gssapi_handle = find_dissector_add_dependency("gssapi", proto_ldap);
5685
15
  gssapi_wrap_handle = find_dissector_add_dependency("gssapi_verf", proto_ldap);
5686
15
  spnego_handle = find_dissector_add_dependency("spnego", proto_ldap);
5687
5688
15
  ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_ldap);
5689
5690
15
  tls_handle = find_dissector_add_dependency("tls", proto_ldap);
5691
5692
15
  prefs_register_ldap();
5693
5694
15
  oid_add_from_string("ISO assigned OIDs, USA",                                                     "1.2.840");
5695
5696
/*  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dsml/dsml/ldap_controls_and_session_support.asp */
5697
/*  https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea */
5698
15
  oid_add_from_string("LDAP_SERVER_SHOW_DELETED_OID","1.2.840.113556.1.4.417");
5699
15
  oid_add_from_string("LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID","1.2.840.113556.1.4.521");
5700
15
  oid_add_from_string("LDAP_SERVER_NOTIFICATION_OID","1.2.840.113556.1.4.528");
5701
15
  oid_add_from_string("LDAP_SERVER_EXTENDED_DN_OID","1.2.840.113556.1.4.529");
5702
15
  oid_add_from_string("meetingAdvertiseScope","1.2.840.113556.1.4.582");
5703
15
  oid_add_from_string("LDAP_SERVER_LAZY_COMMIT_OID","1.2.840.113556.1.4.619");
5704
15
  oid_add_from_string("mhsORAddress","1.2.840.113556.1.4.650");
5705
15
  oid_add_from_string("managedObjects","1.2.840.113556.1.4.654");
5706
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_OID","1.2.840.113556.1.4.800");
5707
15
  oid_add_from_string("LDAP_SERVER_SD_FLAGS_OID","1.2.840.113556.1.4.801");
5708
15
  oid_add_from_string("LDAP_SERVER_RANGE_OPTION_OID","1.2.840.113556.1.4.802");
5709
15
  oid_add_from_string("LDAP_MATCHING_RULE_BIT_AND", "1.2.840.113556.1.4.803");
5710
15
  oid_add_from_string("LDAP_MATCHING_RULE_BIT_OR","1.2.840.113556.1.4.804");
5711
15
  oid_add_from_string("LDAP_SERVER_TREE_DELETE_OID","1.2.840.113556.1.4.805");
5712
15
  oid_add_from_string("LDAP_SERVER_GET_STATS_OID","1.2.840.113556.1.4.970");
5713
15
  oid_add_from_string("LDAP_SERVER_VERIFY_NAME_OID","1.2.840.113556.1.4.1338");
5714
15
  oid_add_from_string("LDAP_SERVER_DOMAIN_SCOPE_OID","1.2.840.113556.1.4.1339");
5715
15
  oid_add_from_string("LDAP_SERVER_SEARCH_OPTIONS_OID","1.2.840.113556.1.4.1340");
5716
15
  oid_add_from_string("LDAP_SERVER_RODC_DCPROMO_OID","1.2.840.113556.1.4.1341");
5717
15
  oid_add_from_string("LDAP_SERVER_PERMISSIVE_MODIFY_OID","1.2.840.113556.1.4.1413");
5718
15
  oid_add_from_string("LDAP_SERVER_ASQ_OID","1.2.840.113556.1.4.1504");
5719
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_V51_OID","1.2.840.113556.1.4.1670");
5720
15
  oid_add_from_string("msDS-SDReferenceDomain","1.2.840.113556.1.4.1711");
5721
15
  oid_add_from_string("msDS-AdditionalDnsHostName","1.2.840.113556.1.4.1717");
5722
15
  oid_add_from_string("LDAP_SERVER_FAST_BIND_OID","1.2.840.113556.1.4.1781");
5723
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_LDAP_INTEG_OID","1.2.840.113556.1.4.1791");
5724
15
  oid_add_from_string("msDS-ObjectReference","1.2.840.113556.1.4.1840");
5725
15
  oid_add_from_string("msDS-QuotaEffective","1.2.840.113556.1.4.1848");
5726
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_ADAM_OID","1.2.840.113556.1.4.1851");
5727
15
  oid_add_from_string("LDAP_SERVER_QUOTA_CONTROL_OID","1.2.840.113556.1.4.1852");
5728
15
  oid_add_from_string("msDS-PortSSL","1.2.840.113556.1.4.1860");
5729
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_ADAM_DIGEST_OID", "1.2.840.113556.1.4.1880");
5730
15
  oid_add_from_string("LDAP_SERVER_SHUTDOWN_NOTIFY_OID","1.2.840.113556.1.4.1907");
5731
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_PARTIAL_SECRETS_OID", "1.2.840.113556.1.4.1920");
5732
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_V60_OID", "1.2.840.113556.1.4.1935");
5733
15
  oid_add_from_string("LDAP_MATCHING_RULE_TRANSITIVE_EVAL", "1.2.840.113556.1.4.1941");
5734
15
  oid_add_from_string("LDAP_SERVER_RANGE_RETRIEVAL_NOERR_OID","1.2.840.113556.1.4.1948");
5735
15
  oid_add_from_string("msDS-isRODC","1.2.840.113556.1.4.1960");
5736
15
  oid_add_from_string("LDAP_SERVER_FORCE_UPDATE_OID","1.2.840.113556.1.4.1974");
5737
15
  oid_add_from_string("LDAP_SERVER_DN_INPUT_OID","1.2.840.113556.1.4.2026");
5738
15
  oid_add_from_string("LDAP_SERVER_SHOW_RECYCLED_OID","1.2.840.113556.1.4.2064");
5739
15
  oid_add_from_string("LDAP_SERVER_SHOW_DEACTIVATED_LINK_OID","1.2.840.113556.1.4.2065");
5740
15
  oid_add_from_string("LDAP_SERVER_POLICY_HINTS_DEPRECATED_OID","1.2.840.113556.1.4.2066");
5741
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_V61_R2_OID", "1.2.840.113556.1.4.2080");
5742
15
  oid_add_from_string("LDAP_SERVER_DIRSYNC_EX_OID","1.2.840.113556.1.4.2090");
5743
15
  oid_add_from_string("LDAP_SERVER_TREE_DELETE_EX_OID","1.2.840.113556.1.4.2204");
5744
15
  oid_add_from_string("LDAP_SERVER_UPDATE_STATS_OID","1.2.840.113556.1.4.2205");
5745
15
  oid_add_from_string("LDAP_SERVER_SEARCH_HINTS_OID","1.2.840.113556.1.4.2206");
5746
15
  oid_add_from_string("LDAP_SERVER_EXPECTED_ENTRY_COUNT_OID","1.2.840.113556.1.4.2211");
5747
15
  oid_add_from_string("LDAP_SERVER_BATCH_REQUEST_OID", "1.2.840.113556.1.4.2212");
5748
15
  oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_W8_OID", "1.2.840.113556.1.4.2237");
5749
15
  oid_add_from_string("LDAP_SERVER_POLICY_HINTS_OID","1.2.840.113556.1.4.2239");
5750
15
  oid_add_from_string("LDAP_MATCHING_RULE_DN_WITH_DATA", "1.2.840.113556.1.4.2253");
5751
15
  oid_add_from_string("LDAP_SERVER_SET_OWNER_OID","1.2.840.113556.1.4.2255");
5752
15
  oid_add_from_string("LDAP_SERVER_BYPASS_QUOTA_OID","1.2.840.113556.1.4.2256");
5753
15
  oid_add_from_string("LDAP_SERVER_LINK_TTL_OID","1.2.840.113556.1.4.2309");
5754
15
  oid_add_from_string("LDAP_SERVER_SET_CORRELATION_ID_OID","1.2.840.113556.1.4.2330");
5755
15
  oid_add_from_string("LDAP_SERVER_THREAD_TRACE_OVERRIDE_OID","1.2.840.113556.1.4.2354");
5756
5757
  /* RFC4532 */
5758
15
  oid_add_from_string("LDAP_SERVER_WHO_AM_I_OID", "1.3.6.1.4.1.4203.1.11.3");
5759
5760
  /* Mark Wahl (Critical Angle) */
5761
15
  oid_add_from_string("DYNAMIC_REFRESH","1.3.6.1.4.1.1466.101.119.1");
5762
15
  oid_add_from_string("LDAP_START_TLS_OID","1.3.6.1.4.1.1466.20037");
5763
5764
15
  oid_add_from_string("inetOrgPerson", "2.16.840.1.113730.3.2.2");
5765
  /* RFC2798 */
5766
15
  oid_add_from_string("US company arc",                                                             "2.16.840.1");
5767
5768
  /* http://www.alvestrand.no/objectid/2.16.840.1.113730.3.4.html */
5769
15
  oid_add_from_string("Manage DSA IT LDAPv3 control",                                               "2.16.840.1.113730.3.4.2");
5770
15
  oid_add_from_string("Persistent Search LDAPv3 control",                                           "2.16.840.1.113730.3.4.3");
5771
15
  oid_add_from_string("Netscape Password Expired LDAPv3 control",                                   "2.16.840.1.113730.3.4.4");
5772
15
  oid_add_from_string("Netscape Password Expiring LDAPv3 control",                                  "2.16.840.1.113730.3.4.5");
5773
15
  oid_add_from_string("Netscape NT Synchronization Client LDAPv3 control",                          "2.16.840.1.113730.3.4.6");
5774
15
  oid_add_from_string("Entry Change Notification LDAPv3 control",                                   "2.16.840.1.113730.3.4.7");
5775
15
  oid_add_from_string("Transaction ID Request Control",                                             "2.16.840.1.113730.3.4.8");
5776
15
  oid_add_from_string("VLV Request LDAPv3 control",                                                 "2.16.840.1.113730.3.4.9");
5777
15
  oid_add_from_string("VLV Response LDAPv3 control",                                                "2.16.840.1.113730.3.4.10");
5778
15
  oid_add_from_string("Transaction ID Response Control",                                            "2.16.840.1.113730.3.4.11");
5779
15
  oid_add_from_string("Proxied Authorization (version 1) control",                                  "2.16.840.1.113730.3.4.12");
5780
15
  oid_add_from_string("iPlanet Directory Server Replication Update Information Control",            "2.16.840.1.113730.3.4.13");
5781
15
  oid_add_from_string("iPlanet Directory Server search on specific backend control",                "2.16.840.1.113730.3.4.14");
5782
15
  oid_add_from_string("Authentication Response Control",                                            "2.16.840.1.113730.3.4.15");
5783
15
  oid_add_from_string("Authentication Request Control",                                             "2.16.840.1.113730.3.4.16");
5784
15
  oid_add_from_string("Real Attributes Only Request Control",                                       "2.16.840.1.113730.3.4.17");
5785
15
  oid_add_from_string("Proxied Authorization (version 2) Control",                                  "2.16.840.1.113730.3.4.18");
5786
15
  oid_add_from_string("Chaining loop detection",                                                    "2.16.840.1.113730.3.4.19");
5787
15
  oid_add_from_string("iPlanet Replication Modrdn Extra Mods Control",                              "2.16.840.1.113730.3.4.999");
5788
5789
5790
15
  ldap_sid_handle = create_dissector_handle(dissect_ldap_sid, proto_ldap);
5791
15
  dissector_add_string("ldap.name", "netlogon", create_dissector_handle(dissect_NetLogon_PDU, proto_cldap));
5792
15
  dissector_add_string("ldap.name", "objectGUID", create_dissector_handle(dissect_ldap_guid, proto_ldap));
5793
15
  dissector_add_string("ldap.name", "supportedControl", create_dissector_handle(dissect_ldap_oid, proto_ldap));
5794
15
  dissector_add_string("ldap.name", "supportedCapabilities", create_dissector_handle(dissect_ldap_oid, proto_ldap));
5795
15
  dissector_add_string("ldap.name", "mS-DS-CreatorSID", ldap_sid_handle);
5796
15
  dissector_add_string("ldap.name", "msDS-QuotaTrustee", ldap_sid_handle);
5797
15
  dissector_add_string("ldap.name", "objectSid", ldap_sid_handle);
5798
15
  dissector_add_string("ldap.name", "securityIdentifier", ldap_sid_handle);
5799
15
  dissector_add_string("ldap.name", "sIDHistory", ldap_sid_handle);
5800
15
  dissector_add_string("ldap.name", "syncWithSID", ldap_sid_handle);
5801
15
  dissector_add_string("ldap.name", "tokenGroups", ldap_sid_handle);
5802
15
  dissector_add_string("ldap.name", "tokenGroupsGlobalAndUniversal", ldap_sid_handle);
5803
15
  dissector_add_string("ldap.name", "tokenGroupsNoGCAcceptable", ldap_sid_handle);
5804
15
  dissector_add_string("ldap.name", "nTSecurityDescriptor", create_dissector_handle(dissect_ldap_nt_sec_desc, proto_ldap));
5805
5806
15
  register_ber_oid_dissector("1.2.840.113556.1.4.319", dissect_SearchControlValue_PDU, proto_ldap, "LDAP_PAGED_RESULT_OID_STRING");
5807
15
  register_ber_oid_dissector("1.2.840.113556.1.4.473", dissect_SortKeyList_PDU, proto_ldap, "LDAP_SERVER_SORT_OID");
5808
15
  register_ber_oid_dissector("1.2.840.113556.1.4.474", dissect_SortResult_PDU, proto_ldap, "LDAP_SERVER_RESP_SORT_OID");
5809
15
  register_ber_oid_dissector("1.2.840.113556.1.4.841", dissect_DirSyncControlValue_PDU, proto_ldap, "LDAP_SERVER_DIRSYNC_OID");
5810
15
  register_ber_oid_dissector("1.3.6.1.4.1.4203.1.11.1", dissect_PasswdModifyRequestValue_PDU, proto_ldap, "passwdModifyOID");
5811
15
  register_ber_oid_dissector("1.3.6.1.1.8", dissect_CancelRequestValue_PDU, proto_ldap, "cancelRequestOID");
5812
15
  register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.1", dissect_SyncRequestValue_PDU, proto_ldap, "syncRequestOID");
5813
15
  register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.2", dissect_SyncStateValue_PDU, proto_ldap, "syncStateOID");
5814
15
  register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.3", dissect_SyncDoneValue_PDU, proto_ldap, "syncDoneOID");
5815
15
  register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.4", dissect_SyncInfoValue_PDU, proto_ldap, "syncInfoOID");
5816
15
  register_ber_oid_dissector("1.3.6.1.4.1.42.2.27.8.5.1", dissect_PasswordPolicyResponseValue_PDU, proto_ldap, "passwordPolicy");
5817
5818
5819
15
 dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE_LDAP, ldap_handle);
5820
5821
15
 dissector_add_uint("acdr.tls_application_port", 636, ldap_handle);
5822
15
 dissector_add_uint("acdr.tls_application", TLS_APP_LDAP, ldap_handle);
5823
15
}
5824
5825
static void
5826
prefs_register_ldap(void)
5827
15
{
5828
15
  if(ssl_port != global_ldaps_tcp_port) {
5829
15
    if(ssl_port)
5830
0
      ssl_dissector_delete(ssl_port, ldap_handle);
5831
5832
    /* Set our port number for future use */
5833
15
    ssl_port = global_ldaps_tcp_port;
5834
5835
15
    if(ssl_port)
5836
15
      ssl_dissector_add(ssl_port, ldap_handle);
5837
15
  }
5838
5839
15
}
5840
5841
/*
5842
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
5843
 *
5844
 * Local Variables:
5845
 * c-basic-offset: 2
5846
 * tab-width: 8
5847
 * indent-tabs-mode: nil
5848
 * End:
5849
 *
5850
 * vi: set shiftwidth=2 tabstop=8 expandtab:
5851
 * :indentSize=2:tabSize=8:noTabs=true:
5852
 */