summaryrefslogtreecommitdiffstats
path: root/sc-ap/ldap1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sc-ap/ldap1.cpp')
-rwxr-xr-xsc-ap/ldap1.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/sc-ap/ldap1.cpp b/sc-ap/ldap1.cpp
index 435c210..08b5eda 100755
--- a/sc-ap/ldap1.cpp
+++ b/sc-ap/ldap1.cpp
@@ -122,31 +122,37 @@ CLDAP::CLDAP( const std::list<mystring>& servers, FILE *fp, const mystring& bind
lp = ldap_init( (const PWCHAR) ptr->c_str(), LDAP_PORT);
ULONG version = LDAP_VERSION3;
if (!lp) {
- fprintf( fp, "ldap_init error on server %S\n", ptr->c_str());
+ if (fp) {
+ fprintf( fp, "ldap_init error on server %S\n", ptr->c_str());
+ }
continue;
}
int ret = ldap_set_option( lp, LDAP_OPT_VERSION, &version);
if (ret != LDAP_SUCCESS) {
- fprintf( fp, "ldap_set_option error %x on server %S\n", ret, ptr->c_str());
- ldap_unbind( lp);
- continue;
+ if (fp) {
+ fprintf( fp, "ldap_set_option error %x on server %S\n", ret, ptr->c_str());
+ }
+ ldap_unbind( lp);
+ continue;
}
if (binddn == L"" || bindpasswd == L"") {
ret = ldap_simple_bind_s( lp, NULL, NULL);
if (LDAP_SUCCESS != ret) {
- if (fp)
+ if (fp) {
fprintf( fp, "anonymous ldap_simple_bind_s error %x on server %S\n", ret, ptr->c_str());
+ }
ldap_unbind( lp);
lp = NULL;
}
} else {
ret = ldap_simple_bind_s( lp, (PWCHAR) binddn.c_str(), (PWCHAR) bindpasswd.c_str());
if (LDAP_SUCCESS != ret) {
- if (fp)
+ if (fp) {
fprintf( fp, "ldap_simple_bind_s error %x on server %S, basedn %S, passwd %S\n",
ret, ptr->c_str(), binddn.c_str(), bindpasswd.c_str());
+ }
ldap_unbind( lp);
lp = NULL;
}