K
Ken Dourado
Hi,
I've got an intranet ASP.NET application that uses Forms Authentication.
What I'd like to do is get the username (in the format name.surname) of
the visitor and then retrieve their Display Name from Active Directory
using the following method:
internal static string GetUserDisplayName(string id)
{
string html = "";
DirectoryEntry objDomain = new DirectoryEntry("LDAP://DOMAINNAME");
DirectorySearcher objSearcher = new DirectorySearcher(objDomain);
objSearcher.Filter = ("(objectClass=user)(sn=" + id ")");
foreach(SearchResult sr in objSearcher.FindAll()) // this line errors
{
DirectoryEntry de = sr.GetDirectoryEntry();
html = de.Properties["DisplayName"].Value.ToString() + "<br>";
}
return html;
}
I keep getting the following error message:
System.Runtime.InteropServices.COMException: The directory service is
unavailable
I'm a newbie at this so I don't really understand where I'm going wrong
or if I have to set anything up before carrying on.
Thanks in advance for any help.
Regards,
Ken.
I've got an intranet ASP.NET application that uses Forms Authentication.
What I'd like to do is get the username (in the format name.surname) of
the visitor and then retrieve their Display Name from Active Directory
using the following method:
internal static string GetUserDisplayName(string id)
{
string html = "";
DirectoryEntry objDomain = new DirectoryEntry("LDAP://DOMAINNAME");
DirectorySearcher objSearcher = new DirectorySearcher(objDomain);
objSearcher.Filter = ("(objectClass=user)(sn=" + id ")");
foreach(SearchResult sr in objSearcher.FindAll()) // this line errors
{
DirectoryEntry de = sr.GetDirectoryEntry();
html = de.Properties["DisplayName"].Value.ToString() + "<br>";
}
return html;
}
I keep getting the following error message:
System.Runtime.InteropServices.COMException: The directory service is
unavailable
I'm a newbie at this so I don't really understand where I'm going wrong
or if I have to set anything up before carrying on.
Thanks in advance for any help.
Regards,
Ken.