Accessing Active Directory in ASP.NET

progame64

New Member
Greetings,<BR>I've got a small problem. I'm trying to get the same <BR>information out of our Active Directory in ASP.NET that I <BR>can get out of VB.NET but am not being successful. <BR>This code works in VB.Net, but returns nothing in ASP.Net <BR>(obviously I have the System.DirectoryServices reference <BR>and in ASP.Net I have changed Console.Writeline to <BR>Response.Write):<BR><BR> Dim DirectorySearcher1 As New <BR>DirectoryServices.DirectorySearcher()<BR> Dim DirectoryEntry1 As New <BR>DirectoryServices.DirectoryEntry()<BR> DirectoryEntry1.Path = "LDAP://MAIN"<BR><BR> DirectorySearcher1.SearchRoot = DirectoryEntry1<BR> DirectorySearcher1.Filter <BR>= "(sAMAccountName=JMauldin)"<BR><BR> Dim result As DirectoryServices.SearchResult<BR><BR> For Each result In DirectorySearcher1.FindAll()<BR> Console.Writeline(result.GetDirectoryEntry.Path & vbCrLf)<BR> Console.Writeline(result.GetDirectoryEntry.Propert ies.Item("cn").Value)<BR> Next<BR><BR>Please advise.<BR><BR>Thanks,<BR><BR>Alan West<BR>
 
Back
Top