Get user's full name from Active Directory

mcdonnc2004
10-10-2006, 09:41 AM
Ok, this has to be one of the easiest but hardest to find out about thing in ASP.NET. All I want to do is query AD and get the fullname for the current user on the site. I have tried about 10 different code tutorials. Some return nothing, others give me a "System.Runtime.InteropServices.COMException: The network path was not found" error. The code below is one of the ones that gives me the "System.Runtime.InteropServices.COMException: The network path was not found" error.

Dim Logon_User, Position, Domain, User As String
Logon_User = Request.ServerVariables("LOGON_USER")


Position = InStr(Logon_User, "\")
Domain = Left(Logon_User, Position - 1)
User = LCase(Mid(Logon_User, Position + 1))


Dim strpath As String = "WinNT://" & Domain & "/" & User
Dim myDE As New System.DirectoryServices.DirectoryEntry(strpath)


Dim coll As System.DirectoryServices.PropertyCollection
coll = myDE.Properties


Dim obVal As Object
obVal = coll("FullName").Value
Response.Write(obVal.ToString() & "<br>")

Does anyone have something that works? I'm really frustrated by this now! :(

Code Jay
10-12-2006, 02:46 AM
Do you require User Full Name from LDAP Server, or you just want user who logged in to Windows..?

mcdonnc2004
10-12-2006, 05:53 AM
Yes, I could use an LDAP query to get the full name from Active Directory but I only know how to use the "WinNT://" function. If you could provide me with an LDAP sample I can modify the LDAP query for our system.

Thanks.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum