Hi, Here is the code that i am using to authenticate a user. this
works fine when i work with localhost(asp.net 2005 inbuilt iis). but
when i deployed the page to a IIS webserver then it throws "An
operations error occurred".
Here is my code:
bool IsExistInAD(string loginName)
{
string userName = loginName;
bool retVal = false;
try
{
string strLDAP = "LDAP://cn=xxxx,ou=xxxDistribution Lists,ou=ZZ
DXB,ou=domainname,dc=SD01,dc=domainname,dc=st";
DirectoryEntry objDirEntry = new DirectoryEntry
(strLDAP, "domainname\\username", "password",
AuthenticationTypes.Secure);
//objDirEntry.Path =
Response.Write(objDirEntry.Username.ToString());
DirectorySearcher search = new DirectorySearcher
(objDirEntry);
search.Filter = String.Format("(SAMAccountName={0})",
userName);
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (result == null)
{
retVal= false;
}
else
{
retVal= true;
}
}
catch (Exception ex)
{
Response.Write("IsExistInAD - " + ex.Message.ToString()
+ "<br>");
Response.Write("IsExistInAD - " + ex.Source.ToString()
+ "<br>");
//Response.Write(userName);
}
Response.Write(retVal.ToString());
return retVal;
}
ALWAYS IT RETURNS FALSE...