LDAP (IPA 内) でユーザー/パスワードを確認する必要があります。これは Novell の例ですが、動作しません
System.String ldapHost = "ipa-server.ipadev.local";
System.String loginDN = "uid=tom,cn=users,cn=compat,dc=ipadev,dc=local";
System.String password = "12345678";
System.String objectDN = "cn=tim,cn=groups,cn=accounts,dc=ipadev,dc=local";
System.String testPassword = "12345678";
LdapConnection conn = new LdapConnection();
conn.SecureSocketLayer = true;
conn.UserDefinedServerCertValidationDelegate += delegate {
return true;
};
try
{
conn.Connect(ldapHost, LdapConnection.DEFAULT_SSL_PORT);
conn.Bind(loginDN, password);
LdapAttribute attr = new LdapAttribute("userPassword", testPassword);
bool correct = conn.Compare(objectDN, attr);
System.Console.Out.WriteLine(correct ? "The password is correct." : "The password is incorrect.\n");
// disconnect with the server
conn.Disconnect();
}
catch (LdapReferralException ex)
{
System.Console.Error.WriteLine ("Error: Referrals exception - " + ex.ToString());
System.Console.Error.WriteLine ("Referrals: " + ex.getReferrals ());
}
catch (LdapException e)
{
if (e.ResultCode == LdapException.NO_SUCH_OBJECT)
{
System.Console.Error.WriteLine("Error: No such entry - " + e.ToString());
}
else if (e.ResultCode == LdapException.NO_SUCH_ATTRIBUTE)
{
System.Console.Error.WriteLine("Error: No such attribute");
}
else
{
System.Console.Error.WriteLine("Error: " + e.ToString());
}
}
catch (System.IO.IOException e)
{
System.Console.Out.WriteLine("Error: " + e.ToString());
}
System.Environment.Exit(0);
空のパスワードを使用すると、バインドは成功しますconn.Compare
が、エラーが発生します -Error: LdapException: (50) Insufficient Access Rights
通常のパスワード (12345678) を使用すると、error "LdapReferralException: (10) Referral"
Bind 内に
もう 1 つの質問 - loginDn 内では のようなフル パスを使用する必要"uid=tom,cn=users,cn=compat,dc=ipadev,dc=local"
がありますが、ユーザーはログインしか所有していません。このフル パスを作成するにはどうすればよいですか?