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