/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
* Copyright (c) 1995 Regents of the University of Michigan.
* All rights reserved.
*
#include "portable.h"
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include "ldap-int.h"
-#ifdef LDAP_DEBUG
-int ldap_debug;
-#endif
-
-
/*
* ldap_open - initialize and connect to an ldap server. A magic cookie to
* be used for future communication is returned on success, NULL on failure.
return( NULL );
}
- /* we'll assume we're talking version 2 for now */
- ld->ld_version = LDAP_VERSION2;
-
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
strdup( ld->ld_defhost )) == NULL )) {
+ if(srv != NULL) free( (char*) srv );
ldap_ld_free( ld, 0 );
return( NULL );
}
return( NULL );
}
+ if ( openldap_ldap_global_options.ldo_defbase != NULL ) {
+ ld->ld_options.ldo_defbase = strdup(
+ openldap_ldap_global_options.ldo_defbase);
+ }
+
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
free( (char*) ld->ld_options.ldo_defhost );
- free( (char*) ld->ld_options.ldo_defbase );
+ if ( ld->ld_options.ldo_defbase == NULL ) {
+ free( (char*) ld->ld_options.ldo_defbase );
+ }
free( (char*) ld );
WSACleanup( );
return( NULL );
#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
+ /* we'll assume we're talking version 2 for now */
+ ld->ld_version = LDAP_VERSION2;
+
+ ld->ld_sb.sb_sd = -1;
return( ld );
}