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! :(
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! :(