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

Re: Problem in fetching user details from LDAP in MOSS by Mike

Mike
Mon Mar 03 22:49:54 CST 2008

Please post programming questions to the programming newsgroup.

microsoft.public,sharepoint.development_and_programming

that's where the programming experts are ...

Mike Walsh
WSS FAQ http://www.wssfaq.com / wss.collutions.com
I regret that private e-mail questions will not be answered


suchismita.83@gmail.com wrote:
> 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