how to take User's Full Name from Active Directory
hi friends,
I am having one problem regarding accessing ActiveDirectory. My requirement is need to display the user name which is available in Activedirectory in the top of the webpage which a application(TimeTracker) we are using in intranet. I search the net and found some codings, they provide for console application and I created a console application and applied the codings, it is working fine all the way. I used the same coding in webapplication but it is not working. Can u able to tell me , why the problem is and can u able to help me to get out of this.
Note: i am using windows authentication.
The following is the code I used in the Page_Load event
DirectoryEntry entry = new DirectoryEntry("LDAP://ECWEB.local");
DirectorySearcher dSearch = new DirectorySearcher(entry);
String Name="krishnaprabhu";// name
dSearch.Filter = "(&(objectClass=user)(givenName=" + Name + "))";
foreach(SearchResult sResultSet in dSearch.FindAll())
{
// Login Name
Response.Write(GetProperty(sResultSet,"cn"));
// First Name
Response.Write(GetProperty(sResultSet,"givenName") );
// Middle Initials
Response.Write(GetProperty(sResultSet,"initials")) ;
// Last Name
Response.Write(GetProperty(sResultSet,"sn"));
// Address
string tempAddress=GetProperty(sResultSet,"homePostalAddr ess");
}
|