[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: List of error messages
Here is a function that gives errors based on return codes... and here
is a link to the ldap_error() man page:
http://www.openldap.org/software/man.cgi?query=ldap_error&sektion=3&apropos=0&manpath=OpenLDAP+2.2-Release
/* Search LDAP/AD for User data */
static int _ldap_search()
{
LDAP *ld, *x;
LDAPMessage *res, *e, *result;
int i, z, rc;
char *a, *dn, msgid;
void *ptr;
char *attrs[5];
char buffer[80];
char *host;
char *base;
int port;
const char *user;
const char *pass;
BerElement **berptr;
BerElement * ber;
udataptr myUser = &localUser;
myConfigPtr myConfig = &localConfig;
berptr = &ber;
attrs[ 0 ] = "cn";
attrs[ 1 ] = "uidNumber";
attrs[ 2 ] = "gidNumber";
attrs[ 3 ] = "loginShell";
attrs[ 4 ] = "msSFUHomeDirectory";
if( myConfig->ldap_servers != NULL ) {
host = myConfig->ldap_servers;
}
if( myConfig->ldap_port != NULL ) {
port = atoi( myConfig->ldap_port );
}
if( myConfig->ldap_user != NULL ) {
user = myConfig->ldap_user;
}
if( myConfig->ldap_pass != NULL ) {
pass = myConfig->ldap_pass;
}
if( myConfig->ldap_base_dn != NULL ) {
base = myConfig->ldap_base_dn;
}
if( ( ld = ldap_init( host, port ) ) == NULL ) {
CRIT( "Initialization Failed: %s", host );
return 0;
}
rc = ldap_simple_bind_s( ld, user, pass );
switch( rc ) {
case LDAP_SUCCESS:
sprintf( buffer, "(cn=%s)", myUser->usrname );
DEBUG( "Searching for: %s", buffer );
if ( ldap_search_s( ld, base, LDAP_SCOPE_SUBTREE,
buffer, NULL, 0, &res ) != LDAP_SUCCESS ) {
CRIT( "No results for %s", buffer );
return 0;
}
if( ldap_first_entry( ld, res ) == NULL ) {
CRIT( "%s not found in LDAP/AD aborting authentication", buffer );
}
for( e = ldap_first_entry( ld, res ); e != NULL; e =
ldap_next_entry( ld, e )) {
if(( vals = ldap_get_values( ld, e, "cn" )) != NULL ) {
for( i = 0; vals[i] != NULL; i++ ) {
strcpy( myConfig->unid, vals[i] );
}
}
if(( vals = ldap_get_values( ld, e, "uidNumber" )) !=
NULL ) {
for( i = 0; vals[i] != NULL; i++ ) {
strcpy( myConfig->def_uid, vals[i] );
}
}
if(( vals = ldap_get_values( ld, e, "gidNumber" )) !=
NULL ) {
for( i = 0; vals[i] != NULL; i++ ) {
strcpy( myConfig->def_gid, vals[i] );
}
}
if(( vals = ldap_get_values( ld, e, "loginShell" )) !=
NULL ) {
for( i = 0; vals[i] != NULL; i++ ) {
if( myConfig->def_shell == NULL ) {
strcpy( myConfig->def_shell, vals[i] );
}
}
}
if(( vals = ldap_get_values( ld, e, "msSFUHomeDirectory"
)) != NULL ) {
for( i = 0; vals[i] != NULL; i++ ) {
if( myConfig->def_home == NULL ) {
strcpy( myConfig->def_home, vals[i] );
}
}
}
}
ldap_msgfree( res );
ldap_unbind( ld );
return;
case LDAP_SERVER_DOWN:
CRIT( "Server Down: %s", myConfig->ldap_servers );
return 0;
case LDAP_PROTOCOL_ERROR:
CRIT( "Protocol Error: %s", myConfig->ldap_servers );
return 0;
case LDAP_OPERATIONS_ERROR:
CRIT( "Operations Error: %s", myConfig->ldap_servers );
return 0;
case LDAP_TIMELIMIT_EXCEEDED:
CRIT( "TimeLimit Exceeded: %s", myConfig->ldap_servers );
return 0;
case LDAP_SIZELIMIT_EXCEEDED:
CRIT( "SizeLimit Exceeded: %s", myConfig->ldap_servers );
return 0;
case LDAP_INVALID_SYNTAX:
CRIT( "Invalid Syntax: %s", myConfig->ldap_servers );
return 0;
case LDAP_INVALID_DN_SYNTAX:
CRIT( "Invalid DN Syntax: %s", myConfig->ldap_servers );
return 0;
case LDAP_INAPPROPRIATE_AUTH:
CRIT( "Inappropriate Auth: %s", myConfig->ldap_servers );
return 0;
case LDAP_INVALID_CREDENTIALS:
CRIT( "Invalid Credentials: %s", myConfig->ldap_servers );
return 0;
case LDAP_UNAVAILABLE:
CRIT( "LDAP Unavailable: %s", myConfig->ldap_servers );
return 0;
case LDAP_BUSY:
CRIT( "LDAP Busy: %s", myConfig->ldap_servers );
return 0;
case LDAP_OTHER:
CRIT( "Other Unspecified Error: %s", myConfig->ldap_servers );
return 0;
case LDAP_LOCAL_ERROR:
CRIT( "Failed Dynamic Memory Allocation: %s",
myConfig->ldap_servers );
return 0;
case LDAP_ENCODING_ERROR:
CRIT( "Encoding Error: %s", myConfig->ldap_servers );
return 0;
case LDAP_TIMEOUT:
CRIT( "Timeout on Results: %s", myConfig->ldap_servers );
return 0;
case LDAP_AUTH_UNKNOWN:
CRIT( "Authentication method for ldap_bind() unknown: %s",
myConfig->ldap_servers );
return 0;
case LDAP_NO_MEMORY:
CRIT( "Memory Error: %s", myConfig->ldap_servers );
return 0;
default:
CRIT( "Error reported: %s\n", myConfig->ldap_servers );
return 0;
}
return 0;
}
Run Out wrote:
So how do you explain that the string "Can't connect to the LDAP
server" appears in libldap30.so?
From: "Kurt D. Zeilenga" <Kurt@OpenLDAP.org>
To: "test test" <runoutoftime@hotmail.com>
CC: OpenLDAP-software@OpenLDAP.org
Subject: Re: List of error messages
Date: Thu, 04 Nov 2004 10:13:29 -0800
At 05:22 AM 11/3/2004, test test wrote:
>Does anyone have a list of error messages that libldap30.so may return?
>91 Can't connect to the LDAP server
That's likely not OpenLDAP Software.
For OpenLDAP's libldap, one can look in libraries/libldap/error.c.
Kurt
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's
FREE! http://messenger.msn.com/
--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
jason.gerfen@scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show