public bool CheckUser(string UserName, string OldPassword)
{
bool result = true;
string User = UserName;
string Pass = OldPassword;
// Creating an LdapConnection instance
Novell.Directory.Ldap.LdapConnection ldapConn = new Novell.Directory.Ldap.LdapConnection();
string dn = "uid = " + UserName + ",ou=users,dc=example,dc=com";
try
{
//Connect function will create a socket connection to the server
ldapConn.Connect(ldapHost, ldapPort);
//Bind function will Bind the user object Credentials to the Server
ldapConn.Bind(dn, OldPassword);
}
catch (Novell.Directory.Ldap.LdapException e)
{
TempData["msg"] = "<script>alert('Could not authenticate user!');</script>";
result = false;
return(result);
}
finally
{
// Disconnect from LDAP
ldapConn.Disconnect();
}
return(result);
}