1

ldap_sasl_bind_s が機能しないという問題がありますが、ldap_simple_bind_s は機能します。

奇妙なことに、ldap_sasl_bind_s は間違ったパスワードでも機能し、ユーザーは正しいパスワードを入力したように感じます。

問題のPFAコードスニペットと、私のアプローチに問題がある場合は提案してください。

{
int rc, aReturnVal = 0;
NSString *aUserDN = [NSString stringWithFormat:@"uid=%s,cn=users,dc=example,dc=com", username];
char* userDN = (char*)[aUserDN UTF8String];
rc = ldap_simple_bind_s (
                       ld,
                       userDN,
                       password
                       );

    // TODO: ldap_simple_bind_s is a deprecated method and should not be used for long. ldap_sasl_bind_s is the right method, but is not working for now.
    // Find the reason and get this code up and running.
//  struct berval *servcred;
//  struct berval cred;
//  cred.bv_val = password; // my password
//  cred.bv_len = strlen(password);
//  rc = ldap_sasl_bind_s (
//               ld,
//               userDN,
//               "DIGEST-MD5",
//               &cred,
//               NULL,
//               NULL,
//               &servcred
//             );

if ( rc != LDAP_SUCCESS ) {
    fprintf( stderr, "ldap_sasl_bind: %s\n", ldap_err2string( rc ) );
} else {
    aReturnVal = 1;
}

return aReturnVal;
}

次のコード SNIP を使用して LDAP を初期化しました。

rc = ldap_initialize(&ld, HOSTNAME);
version = LDAP_VERSION3;
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
ldap_set_option( ld, LDAP_OPT_REFERRALS, 0 );

正しいユーザー名でログインできるようにする必要があり、ユーザーが間違ったユーザー名を入力しようとすると、ldap がそう言うはずです。

この結論に到達するために、次のリンクとその関連リンクを参照しました。

LDAP - ユーザー名とパスワードの組み合わせを確認するには?

LDAP を使用してユーザーのパスワード認証を行うには?

4

1 に答える 1