Hi,
I am trying to fetch some of user properties from LDAP.Here my
filtering criteria is user name.
The code is working fine when running in local host.But not working
properly when running inside sharepoint site collection.Like..
I am not able to fetch all properties though its existing.Here is my
code
string fullName = string.Empty;
string email = string.Empty;
DirectoryEntry entry = new DirectoryEntry("LDAP://
172.31.45.196/
DC=Globalinsight,DC=com", "administrator", "issglobal");
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + TextBox1.Text + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (result != null)
{
entry = result.GetDirectoryEntry();
//results = search.FindAll();
if (entry.Properties["givenName"].Value != null)
{
fullName =
(entry.Properties["givenName"].Value).ToString();
}
if (entry.Properties["sn"].Value != null)
{
fullName = fullName + " " +
(entry.Properties["sn"].Value).ToString();
}
if (entry.Properties["email"].Value != null)
{
email = (entry.Properties["email"].Value).ToString();
}
Response.Write(fullName+" "+ email);
}
else
{
Response.Write("false");
}
Here I am able to fetch fullName,but not email though it exists.
Please help.Does it need some settings to do in Web.Config file .
TIA