mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
slapi_ldap_init() / slapi_ldap_unbind()
This commit is contained in:
parent
ba686c399b
commit
ab48d0295d
@ -149,6 +149,9 @@ extern void slapi_destroy_condvar( Slapi_CondVar *cvar );
|
||||
extern int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
|
||||
extern int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
|
||||
|
||||
extern LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
|
||||
extern void slapi_ldap_unbind( LDAP *ld );
|
||||
|
||||
extern char *slapi_ch_malloc( unsigned long size );
|
||||
extern void slapi_ch_free( void **ptr );
|
||||
extern void slapi_ch_free_string( char **s );
|
||||
|
@ -4194,3 +4194,43 @@ void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid )
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared )
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
LDAP *ld;
|
||||
char *url;
|
||||
size_t size;
|
||||
int rc;
|
||||
|
||||
size = sizeof("ldap:///");
|
||||
if ( secure )
|
||||
size++;
|
||||
size += strlen( ldaphost );
|
||||
if ( ldapport != 0 )
|
||||
size += 32;
|
||||
|
||||
url = slapi_ch_malloc( size );
|
||||
|
||||
if ( ldapport != 0 ) {
|
||||
sprintf( url, "ldap%s://%s:%d/", ( secure ? "s" : "" ), ldaphost, ldapport );
|
||||
} else {
|
||||
sprintf( url, "ldap%s://%s/", ( secure ? "s" : "" ), ldaphost );
|
||||
}
|
||||
|
||||
rc = ldap_initialize( &ld, url );
|
||||
|
||||
slapi_ch_free_string( &url );
|
||||
|
||||
return ( rc == LDAP_SUCCESS ) ? ld : NULL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
void slapi_ldap_unbind( LDAP *ld )
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
ldap_unbind( ld );
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user