J
JC
Hello.
I am 100% stumped by this and am very needy of a fix.
Please help me figure out why this code does not work-
I can access active directory information but can not return email address.
Here's the code---
Dim Root As New DirectoryEntry("LDAP://dc=dcomp1,dc=net")
Dim Searcher As New DirectorySearcher(Root)
With Searcher
..Filter = "(sAMAccountName=" & Environment.UserName & ")"
..SearchScope = SearchScope.Subtree
..PropertiesToLoad.Add("mail")
End With
Dim Result As SearchResult = Searcher.FindOne
Dim EMailAddress As String
If Not Result Is Nothing Then
EMailAddress = Result.GetDirectoryEntry.Properties("mail").Value
End If
Return EMailAddress
I keep getting "EMailAddress=nothing"
PLEASE help me figure this out.
Jeff
I am 100% stumped by this and am very needy of a fix.
Please help me figure out why this code does not work-
I can access active directory information but can not return email address.
Here's the code---
Dim Root As New DirectoryEntry("LDAP://dc=dcomp1,dc=net")
Dim Searcher As New DirectorySearcher(Root)
With Searcher
..Filter = "(sAMAccountName=" & Environment.UserName & ")"
..SearchScope = SearchScope.Subtree
..PropertiesToLoad.Add("mail")
End With
Dim Result As SearchResult = Searcher.FindOne
Dim EMailAddress As String
If Not Result Is Nothing Then
EMailAddress = Result.GetDirectoryEntry.Properties("mail").Value
End If
Return EMailAddress
I keep getting "EMailAddress=nothing"
PLEASE help me figure this out.
Jeff