c# - Verify password Mono + IPA(LDAP) + rhel -
i need verify user/password in ldap (inside ipa). example novell, not working
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 correct." : "the password incorrect.\n"); // disconnect 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);
if use empty password - bind successful, conn.compare
gives error - error: ldapexception: (50) insufficient access rights
if use normal password (12345678), - error "ldapreferralexception: (10) referral"
inside bind
and 1 more question - inside logindn should use full path "uid=tom,cn=users,cn=compat,dc=ipadev,dc=local"
, user owns login, how create full path?
that's not how in ldap. idea connect as user password, , see if succeeds.
Comments
Post a Comment