]> git.sur5r.net Git - openldap/commitdiff
correct callback numbering
authorKurt Zeilenga <kurt@openldap.org>
Tue, 14 Mar 2000 02:59:53 +0000 (02:59 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 14 Mar 2000 02:59:53 +0000 (02:59 +0000)
libraries/libldap/sasl.c

index c0d649b913d2d3246d75a16b1d3b3a3eae07eba9..00079c52b80b992d1469c2d3e3d643dde2e85532 100644 (file)
@@ -825,21 +825,27 @@ ldap_negotiated_sasl_bind_s(
        LDAPControl **serverControls,
        LDAPControl **clientControls)
 {
+       int n;
        sasl_callback_t callbacks[4];
        int rc;
 
-       callbacks[0].id = SASL_CB_USER;
-       callbacks[0].proc = ldap_pvt_sasl_getsimple;
-       callbacks[1].context = (void *)authenticationId;
-       callbacks[1].id = SASL_CB_AUTHNAME;
-       callbacks[1].proc = ldap_pvt_sasl_getsimple;
-       callbacks[0].context = (void *)authorizationId;
-       callbacks[2].id = SASL_CB_PASS;
-       callbacks[2].proc = ldap_pvt_sasl_getsecret;
-       callbacks[2].context = (void *)passPhrase;
-       callbacks[3].id = SASL_CB_LIST_END;
-       callbacks[3].proc = NULL;
-       callbacks[3].context = NULL;
+       callbacks[n=0].id = SASL_CB_USER;
+       callbacks[n].proc = ldap_pvt_sasl_getsimple;
+       callbacks[n].context = (void *)authenticationId;
+
+       if( authorizationId != NULL ) {
+               callbacks[++n].id = SASL_CB_AUTHNAME;
+               callbacks[n].proc = ldap_pvt_sasl_getsimple;
+               callbacks[n].context = (void *)authorizationId;
+       }
+
+       callbacks[++n].id = SASL_CB_PASS;
+       callbacks[n].proc = ldap_pvt_sasl_getsecret;
+       callbacks[n].context = (void *)passPhrase;
+
+       callbacks[++n].id = SASL_CB_LIST_END;
+       callbacks[n].proc = NULL;
+       callbacks[n].context = NULL;
 
        rc = ldap_pvt_sasl_bind(ld, dn, saslMechanism, callbacks,
                serverControls, clientControls);