Re: LDAP, Email



Thanks Joe and Henning,

I will look further into this.

"Joe Kaplan (MVP - ADSI)" wrote:

It is a little cleaner to actually specify the default naming context of the
domain as the search root explicitly instead of trying to rely on ADSI to
figure that out for you. I'd also recommend against using NETBIOS names for
AD. DNS is always better. I'd do this (works in 1.1 or 2.0; 2.0 has other
better options as well):

Dim rootDSE as DirectoryEntry = New
DirectoryEntry("LDAP://abc.xxx.xxx/RootDSE";)
dnc = DirectCast(rootDSE.Properties("defaultNamingContext").Value, String)

oDS = New DirectoryEntry("LDAP://abc.xxx.xxx/"; + dnc)

And proceed from there.

Another thing to consider is that you are using default credentials in your
bind. If your current security context is not a domain identity or cannot
be delegated, you might be authenticating with the server as an anonymous
user and might therefore not have permissions to see anything. If you
suspect that is true, try changing your DirectoryEntry constructor to supply
some know good credentials for testing. If that fixes it, then you know you
have a security problem.

Joe K.


"Dianna" <Dianna@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:71E8401D-7DD8-4C6A-A395-E8141BBC425B@xxxxxxxxxxxxxxxx
Hi Henning,
_path = LDAP://
_domain = ABC
so it looks like LDAP://ABC

The user name is the Windows it ex: ABC/jsmith



"Dianna" wrote:

Hi,

I am trying to retrieve the email from AD for a specific user, I am
getting
no results. The below code sends in a username that has an email address:

Dim oDS As New DirectorySearcher(_path & _domain)
oDS.Filter = "(samAccountName=" + Username + ")"
oDS.PropertiesToLoad.Add("mail")
Dim res As SearchResult = oDS.FindOne()
Dim strEmail As String

If Not IsNothing(res) Then
Dim deUser As DirectoryEntry = res.GetDirectoryEntry()
strEmail = deUser.Properties("mail").Value.ToString()
End If
What am I doing wrong. I'm very new to LDAP, but the above seems simple
enough...?
Thanks,
Dianna




.



Relevant Pages

  • Re: Get SAMAccountNames for all users in an active directory group
    ... what is the point of the impersonation code? ... Dim arrListSAMAccounts As New ArrayList ... Dim searchRoot As DirectoryEntry = Nothing ...
    (microsoft.public.windows.server.active_directory)
  • System.Byte[] And System.__ComObject in Active Directory LDAP brow
    ... If you use the DirectoryEntry, it marshals the value as an ADSI ... dim pwdDate as DateTime ... Imports System.DirectoryServices ... Private Sub LDAPBrowser_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.general)
  • System.Byte[] And System.__ComObject in AD LDAP Browser
    ... If you use the DirectoryEntry, it marshals the value as an ADSI ... dim pwdDate as DateTime ... Imports System.DirectoryServices ... Private Sub LDAPBrowser_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ADODB to ADO.NET conversion
    ... DirectoryEntry item = result.GetDirectoryEntry; ... Dim entry As New ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: LDAP, Email
    ... I found what my problem was in my original code: the username. ... Dim oDS As New DirectorySearcher ... Dim strEmail As String ... Dim rootDSE as DirectoryEntry = New ...
    (microsoft.public.dotnet.security)