Skip to content

Commit 450bed6

Browse files
committed
Add explicit result code constants, update string mapping
1 parent f40c46e commit 450bed6

File tree

1 file changed

+96
-22
lines changed

1 file changed

+96
-22
lines changed

lib/net/ldap.rb

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -321,29 +321,103 @@ class LdapError < StandardError; end
321321

322322
StartTlsOid = "1.3.6.1.4.1.1466.20037"
323323

324+
# https://tools.ietf.org/html/rfc4511#section-4.1.9
325+
# https://tools.ietf.org/html/rfc4511#appendix-A
326+
ResultCodeSuccess = 0
327+
ResultCodeOperationsError = 1
328+
ResultCodeProtocolError = 2
329+
ResultCodeTimeLimitExceeded = 3
330+
ResultCodeSizeLimitExceeded = 4
331+
ResultCodeCompareFalse = 5
332+
ResultCodeCompareTrue = 6
333+
ResultCodeAuthMethodNotSupported = 7
334+
ResultCodeStrongerAuthRequired = 8
335+
ResultCodeReferral = 10
336+
ResultCodeAdminLimitExceeded = 11
337+
ResultCodeUnavailableCriticalExtension = 12
338+
ResultCodeConfidentialityRequired = 13
339+
ResultCodeSaslBindInProgress = 14
340+
ResultCodeNoSuchAttribute = 16
341+
ResultCodeUndefinedAttributeType = 17
342+
ResultCodeInappropriateMatching = 18
343+
ResultCodeConstraintViolation = 19
344+
ResultCodeAttributeOrValueExists = 20
345+
ResultCodeInvalidAttributeSyntax = 21
346+
ResultCodeNoSuchObject = 32
347+
ResultCodeAliasProblem = 33
348+
ResultCodeInvalidDNSyntax = 34
349+
ResultCodeAliasDereferencingProblem = 36
350+
ResultCodeInappropriateAuthentication = 48
351+
ResultCodeInvalidCredentials = 49
352+
ResultCodeInsufficientAccessRights = 50
353+
ResultCodeBusy = 51
354+
ResultCodeUnavailable = 52
355+
ResultCodeUnwillingToPerform = 53
356+
ResultCodeNamingViolation = 64
357+
ResultCodeObjectClassViolation = 65
358+
ResultCodeNotAllowedOnNonLeaf = 66
359+
ResultCodeNotAllowedOnRDN = 67
360+
ResultCodeEntryAlreadyExists = 68
361+
ResultCodeObjectClassModsProhibited = 69
362+
ResultCodeAffectsMultipleDSAs = 71
363+
ResultCodeOther = 80
364+
365+
# https://tools.ietf.org/html/rfc4511#appendix-A.1
366+
ResultCodesNonError = [
367+
ResultCodeSuccess,
368+
ResultCodeCompareFalse,
369+
ResultCodeCompareTrue,
370+
ResultCodeReferral,
371+
ResultCodeSaslBindInProgress
372+
]
373+
374+
# nonstandard list of "successful" result codes for searches
375+
ResultCodesSearchSuccess = [
376+
ResultCodeSuccess,
377+
ResultCodeTimeLimitExceeded,
378+
ResultCodeSizeLimitExceeded
379+
]
380+
381+
# map of result code to human message
324382
ResultStrings = {
325-
0 => "Success",
326-
1 => "Operations Error",
327-
2 => "Protocol Error",
328-
3 => "Time Limit Exceeded",
329-
4 => "Size Limit Exceeded",
330-
10 => "Referral",
331-
12 => "Unavailable crtical extension",
332-
14 => "saslBindInProgress",
333-
16 => "No Such Attribute",
334-
17 => "Undefined Attribute Type",
335-
19 => "Constraint Violation",
336-
20 => "Attribute or Value Exists",
337-
32 => "No Such Object",
338-
34 => "Invalid DN Syntax",
339-
48 => "Inappropriate Authentication",
340-
49 => "Invalid Credentials",
341-
50 => "Insufficient Access Rights",
342-
51 => "Busy",
343-
52 => "Unavailable",
344-
53 => "Unwilling to perform",
345-
65 => "Object Class Violation",
346-
68 => "Entry Already Exists"
383+
ResultCodeSuccess => "Success",
384+
ResultCodeOperationsError => "Operations Error",
385+
ResultCodeProtocolError => "Protocol Error",
386+
ResultCodeTimeLimitExceeded => "Time Limit Exceeded",
387+
ResultCodeSizeLimitExceeded => "Size Limit Exceeded",
388+
ResultCodeCompareFalse => "False Comparison",
389+
ResultCodeCompareTrue => "True Comparison",
390+
ResultCodeAuthMethodNotSupported => "Auth Method Not Supported",
391+
ResultCodeStrongerAuthRequired => "Stronger Auth Needed",
392+
ResultCodeReferral => "Referral",
393+
ResultCodeAdminLimitExceeded => "Admin Limit Exceeded",
394+
ResultCodeUnavailableCriticalExtension => "Unavailable crtical extension",
395+
ResultCodeConfidentialityRequired => "Confidentiality Required",
396+
ResultCodeSaslBindInProgress => "saslBindInProgress",
397+
ResultCodeNoSuchAttribute => "No Such Attribute",
398+
ResultCodeUndefinedAttributeType => "Undefined Attribute Type",
399+
ResultCodeInappropriateMatching => "Inappropriate Matching",
400+
ResultCodeConstraintViolation => "Constraint Violation",
401+
ResultCodeAttributeOrValueExists => "Attribute or Value Exists",
402+
ResultCodeInvalidAttributeSyntax => "Invalide Attribute Syntax",
403+
ResultCodeNoSuchObject => "No Such Object",
404+
ResultCodeAliasProblem => "Alias Problem",
405+
ResultCodeInvalidDNSyntax => "Invalid DN Syntax",
406+
ResultCodeAliasDereferencingProblem => "Alias Dereferencing Problem",
407+
ResultCodeInappropriateAuthentication => "Inappropriate Authentication",
408+
ResultCodeInvalidCredentials => "Invalid Credentials",
409+
ResultCodeInsufficientAccessRights => "Insufficient Access Rights",
410+
ResultCodeBusy => "Busy",
411+
ResultCodeUnavailable => "Unavailable",
412+
ResultCodeUnwillingToPerform => "Unwilling to perform",
413+
ResultCodeNamingViolation => "Naming Violation",
414+
ResultCodeObjectClassViolation => "Object Class Violation",
415+
ResultCodeNotAllowedOnNonLeaf => "Not Allowed On Non-Leaf",
416+
ResultCodeNotAllowedOnRDN => "Not Allowed On RDN",
417+
ResultCodeEntryAlreadyExists => "Entry Already Exists",
418+
ResultCodeObjectClassModsProhibited => "ObjectClass Modifications Prohibited",
419+
ResultCodeAffectsMultipleDSAs => "Affects Multiple DSAs",
420+
ResultCodeOther => "Other"
347421
}
348422

349423
module LDAPControls

0 commit comments

Comments
 (0)