Help with ADSI C#

S

Sumana

My code is as shown below. I am trying to extract the logged on user's
email id. I get all properties except emailid.
Please can anybody help.
Thanks
Sumana

public void getemail()
{
DirectoryEntry entry = new DirectoryEntry("LDAP://xyz");
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(cn=" + Session["UserId"].ToString()+ ")";

search.SearchScope = SearchScope.Subtree;


foreach(SearchResult result in search.FindAll())
{
foreach(string propertyname in result.Properties.PropertyNames)
{
Trace.Warn(propertyname);
Trace.Warn(result.Properties[propertyname][0].ToString());
}

}
}
 
W

Willy Denoyette [MVP]

What makes you think there is such a property in the directory?
What directory service are you connecting to?
What object are you binding to?
Willy.
 
S

Sumana

Hello Willy,
I can get the displayname and when the user password expires etc
from the directory services. I read many posts where in you can
extract email ids. I was pretty sure there would be a key called
emailaddress or mail for which i can get the value. Am i missing
something or what is the other way of getting email ids of the users
connected to the above domain.
Thanks
Sumana
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top