Mike Broderick
asked on
Use DirectoryServices DirectoryEntry without passing userid or password.
I am trying to use the DirectoryServices' DirectoryEntry class to retrieve the email address for a given user. I do not want to pass a user id/password, but would rather use windows authentication. The only way I could get it to work though is to pass a valid user and password. Is there a way to do this without a userid/password?
Dim adPath As String = String.Format("LDAP://<SID={0}>", userSid)
'Create DE object
Dim sidBind As DirectoryEntry = New DirectoryEntry( _
adPath, _
"", _
"")
'retrieve e-mail address property
If sidBind.Properties.Contains("mail") Then
Return sidBind.Properties("mail").Value.ToString()
Else
Return String.Empty
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dim sidBind As DirectoryEntry = New DirectoryEntry( _
adPath, _
LogInName, _
Nothing, _
AuthenticationTypes.Secure