17 static struct ldaperror ldap_errlist[] = {
18 {LDAP_SUCCESS, "Success" },
19 {LDAP_OPERATIONS_ERROR, "Operations error" },
20 {LDAP_PROTOCOL_ERROR, "Protocol error" },
21 {LDAP_TIMELIMIT_EXCEEDED, "Time limit exceeded" },
22 {LDAP_SIZELIMIT_EXCEEDED, "Size limit exceeded" },
23 {LDAP_COMPARE_FALSE, "Compare false" },
24 {LDAP_COMPARE_TRUE, "Compare true" },
25 {LDAP_STRONG_AUTH_NOT_SUPPORTED, "Strong authentication not supported" },
26 {LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required" },
27 {LDAP_PARTIAL_RESULTS, "Partial results and referral received" },
29 {LDAP_REFERRAL, "Referral"},
30 {LDAP_ADMINLIMIT_EXCEEDED, "Administrative limit exceeded"},
31 {LDAP_UNAVAILABLE_CRITICIAL_EXTENSION,
32 "Criticial extension is unavailable"},
33 {LDAP_CONFIDENTIALITY_REQUIRED, "Confidentiality required"},
34 {LDAP_SASL_BIND_IN_PROGRESS, "SASL bind in progress"},
36 {LDAP_NO_SUCH_ATTRIBUTE, "No such attribute" },
37 {LDAP_UNDEFINED_TYPE, "Undefined attribute type" },
38 {LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching" },
39 {LDAP_CONSTRAINT_VIOLATION, "Constraint violation" },
40 {LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists" },
41 {LDAP_INVALID_SYNTAX, "Invalid syntax" },
43 {LDAP_NO_SUCH_OBJECT, "No such object" },
44 {LDAP_ALIAS_PROBLEM, "Alias problem" },
45 {LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax" },
46 {LDAP_IS_LEAF, "Object is a leaf" },
47 {LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem" },
49 {LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication" },
50 {LDAP_INVALID_CREDENTIALS, "Invalid credentials" },
51 {LDAP_INSUFFICIENT_ACCESS, "Insufficient access" },
52 {LDAP_BUSY, "DSA is busy" },
53 {LDAP_UNAVAILABLE, "DSA is unavailable" },
54 {LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform" },
55 {LDAP_LOOP_DETECT, "Loop detected" },
57 {LDAP_NAMING_VIOLATION, "Naming violation" },
58 {LDAP_OBJECT_CLASS_VIOLATION, "Object class violation" },
59 {LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf" },
60 {LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN" },
61 {LDAP_ALREADY_EXISTS, "Already exists" },
62 {LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class" },
63 {LDAP_RESULTS_TOO_LARGE, "Results too large" },
64 {LDAP_AFFECTS_MULTIPLE_DSAS, "Operation affects multiple DSAs" },
66 {LDAP_OTHER, "Unknown error" },
67 {LDAP_SERVER_DOWN, "Can't contact LDAP server" },
68 {LDAP_LOCAL_ERROR, "Local error" },
69 {LDAP_ENCODING_ERROR, "Encoding error" },
70 {LDAP_DECODING_ERROR, "Decoding error" },
71 {LDAP_TIMEOUT, "Timed out" },
72 {LDAP_AUTH_UNKNOWN, "Unknown authentication method" },
73 {LDAP_FILTER_ERROR, "Bad search filter" },
74 {LDAP_USER_CANCELLED, "User cancelled operation" },
75 {LDAP_PARAM_ERROR, "Bad parameter to an ldap routine" },
76 {LDAP_NO_MEMORY, "Out of memory" },
78 {LDAP_CONNECT_ERROR, "Connect error" },
79 {LDAP_NOT_SUPPORTED, "Not Supported" },
80 {LDAP_CONTROL_NOT_FOUND, "Control not found" },
81 {LDAP_NO_RESULTS_RETURNED, "No results returned" },
82 {LDAP_MORE_RESULTS_TO_RETURN, "More results to return" },
83 {LDAP_CLIENT_LOOP, "Client Loop" },
84 {LDAP_REFERRAL_LIMIT_EXCEEDED, "Referral Limit Exceeded" },
90 ldap_err2string( int err )
94 Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 );
96 for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
97 if ( err == ldap_errlist[i].e_code )
98 return( ldap_errlist[i].e_reason );
101 return( "Unknown error" );
106 ldap_perror( LDAP *ld, char *s )
110 Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 );
117 for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
118 if ( ld->ld_errno == ldap_errlist[i].e_code ) {
119 fprintf( stderr, "%s: %s\n", s,
120 ldap_errlist[i].e_reason );
121 if ( ld->ld_matched != NULL && *ld->ld_matched != '\0' )
122 fprintf( stderr, "%s: matched: %s\n", s,
124 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
125 fprintf( stderr, "%s: additional info: %s\n",
132 fprintf( stderr, "%s: Not an LDAP errno %d\n", s, ld->ld_errno );
137 ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit )
144 Debug( LDAP_DEBUG_TRACE, "ldap_result2error\n", 0, 0, 0 );
147 return( LDAP_PARAM_ERROR );
149 for ( lm = r; lm->lm_chain != NULL; lm = lm->lm_chain )
152 if ( ld->ld_error ) {
153 free( ld->ld_error );
156 if ( ld->ld_matched ) {
157 free( ld->ld_matched );
158 ld->ld_matched = NULL;
162 if ( ld->ld_version == LDAP_VERSION2 ) {
163 rc = ber_scanf( &ber, "{iaa}", &along, &ld->ld_matched,
166 rc = ber_scanf( &ber, "{ia}", &along, &ld->ld_error );
168 if ( rc == LBER_ERROR ) {
169 ld->ld_errno = LDAP_DECODING_ERROR;
171 ld->ld_errno = (int) along;
177 return( ld->ld_errno );