Hi All,
I designed a webpart that brings the employee info according to the EmployeeId stored in active directory, this webpart must be deployed in MySite for every user and then get the employeeId from active directory for the current user "mysite" owner, for testing purposes I deployed the webpart in the intranet site and logged in with a different accounts and faced NO problems, but when I deployed it in mysite an exception thrown in the LDAP query that gets the employee number, below is the code where the exception is thrown.
private int GetEmployeeNumber()
{
try
{
string userName = (SPContext.Current.Web.CurrentUser.LoginName.Trim("MyDomain\\".ToCharArray())).ToString();
int EmployeeID = 0;
DirectoryEntry root = new DirectoryEntry("LDAP://dc=asezahq,dc=net");
DirectorySearcher searcher = new DirectorySearcher(root);
searcher.Filter = "samaccountname=" + userName;
searcher.PropertiesToLoad.Add("employeeID");
//TODO : Handle no user exception
SearchResult res = searcher.FindOne();
root.Close();
DirectoryEntry de = new DirectoryEntry(res.Path);
EmployeeID = int.Parse(de.Properties["employeeID"].Value.ToString());
de.Close();
return EmployeeID;
}
catch (Exception ex)
{
throw ex;
}
}
The Line SearchResult res = searcher.FindOne();
throws the exception "An operations error occurred", I granted the account -under which the MySite application pool runs- the account operator permission but still have the problem.
Can any one helps me please.
Thanks