18 static struct ldaperror ldap_errlist[] = {
19 {LDAP_SUCCESS, "Success" },
20 {LDAP_OPERATIONS_ERROR, "Operations error" },
21 {LDAP_PROTOCOL_ERROR, "Protocol error" },
22 {LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded" },
23 {LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded" },
24 {LDAP_COMPARE_FALSE, "Compare false" },
25 {LDAP_COMPARE_TRUE, "Compare true" },
26 {LDAP_STRONG_AUTH_NOT_SUPPORTED, "Strong authentication not supported" },
27 {LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required" },
28 {LDAP_PARTIAL_RESULTS, "Partial results and referral received" },
29 {LDAP_NO_SUCH_ATTRIBUTE, "No such attribute" },
30 {LDAP_UNDEFINED_TYPE, "Undefined attribute type" },
31 {LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching" },
32 {LDAP_CONSTRAINT_VIOLATION, "Constraint violation" },
33 {LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists" },
34 {LDAP_INVALID_SYNTAX, "Invalid syntax" },
35 {LDAP_NO_SUCH_OBJECT, "No such object" },
36 {LDAP_ALIAS_PROBLEM, "Alias problem" },
37 {LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax" },
38 {LDAP_IS_LEAF, "Object is a leaf" },
39 {LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem" },
40 {LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication" },
41 {LDAP_INVALID_CREDENTIALS, "Invalid credentials" },
42 {LDAP_INSUFFICIENT_ACCESS, "Insufficient access" },
43 {LDAP_BUSY, "DSA is busy" },
44 {LDAP_UNAVAILABLE, "DSA is unavailable" },
45 {LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform" },
46 {LDAP_LOOP_DETECT, "Loop detected" },
47 {LDAP_NAMING_VIOLATION, "Naming violation" },
48 {LDAP_OBJECT_CLASS_VIOLATION, "Object class violation" },
49 {LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf" },
50 {LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN" },
51 {LDAP_ALREADY_EXISTS, "Already exists" },
52 {LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class" },
53 {LDAP_RESULTS_TOO_LARGE, "Results too large" },
54 {LDAP_OTHER, "Unknown error" },
55 {LDAP_SERVER_DOWN, "Can't contact LDAP server" },
56 {LDAP_LOCAL_ERROR, "Local error" },
57 {LDAP_ENCODING_ERROR, "Encoding error" },
58 {LDAP_DECODING_ERROR, "Decoding error" },
59 {LDAP_TIMEOUT, "Timed out" },
60 {LDAP_AUTH_UNKNOWN, "Unknown authentication method" },
61 {LDAP_FILTER_ERROR, "Bad search filter" },
62 {LDAP_USER_CANCELLED, "User cancelled operation" },
63 {LDAP_PARAM_ERROR, "Bad parameter to an ldap routine" },
64 {LDAP_NO_MEMORY, "Out of memory" },
69 ldap_err2string( int err )
73 Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 );
75 for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
76 if ( err == ldap_errlist[i].e_code )
77 return( ldap_errlist[i].e_reason );
80 return( "Unknown error" );
83 #ifndef NO_USERINTERFACE
85 ldap_perror( LDAP *ld, char *s )
89 Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 );
96 for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
97 if ( ld->ld_errno == ldap_errlist[i].e_code ) {
98 fprintf( stderr, "%s: %s\n", s,
99 ldap_errlist[i].e_reason );
100 if ( ld->ld_matched != NULL && *ld->ld_matched != '\0' )
101 fprintf( stderr, "%s: matched: %s\n", s,
103 if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
104 fprintf( stderr, "%s: additional info: %s\n",
111 fprintf( stderr, "%s: Not an LDAP errno %d\n", s, ld->ld_errno );
118 ldap_perror( LDAP *ld, char *s )
122 #endif /* NO_USERINTERFACE */
126 ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit )
133 Debug( LDAP_DEBUG_TRACE, "ldap_result2error\n", 0, 0, 0 );
136 return( LDAP_PARAM_ERROR );
138 for ( lm = r; lm->lm_chain != NULL; lm = lm->lm_chain )
141 if ( ld->ld_error ) {
142 free( ld->ld_error );
145 if ( ld->ld_matched ) {
146 free( ld->ld_matched );
147 ld->ld_matched = NULL;
151 if ( ld->ld_version == LDAP_VERSION2 ) {
152 rc = ber_scanf( &ber, "{iaa}", &along, &ld->ld_matched,
155 rc = ber_scanf( &ber, "{ia}", &along, &ld->ld_error );
157 if ( rc == LBER_ERROR ) {
158 ld->ld_errno = LDAP_DECODING_ERROR;
160 ld->ld_errno = (int) along;
166 return( ld->ld_errno );