locked
Retrieve Active Directory OU by user name RRS feed

  • Question

  • Hi All

    I am trying to retrieve the AD attributes for a particular username so I can generate an email for that user after pulling their address.

    However I have found that not all users have the same OU as me, so I need to exract by user and use the ou as a parm in the email retrieval.

    Set sysInfo = CreateObject("ADSystemInfo")
    Debug.Print sysInfo.UserName
    On Error Resume Next
    Set oUser = GetObject("LDAP://CN=" & ownername & ",OU=Users,OU=????? Brisbane,DC=ch4,DC=com,DC=au")
    Debug.Print oUser.EmailAddress

    I need to extract the bold part first.

    Any ideas?

    Thanks
    Sean
    Thursday, November 7, 2013 2:05 AM

Answers

  • Sub Test()
      Debug.Print GetObject("LDAP://" & CreateObject("ADSystemInfo").UserName).Mail
    End Sub

    • Marked as answer by George Hua Friday, November 15, 2013 3:58 PM
    Thursday, November 7, 2013 11:19 AM

All replies

  • Sub Test()
      Debug.Print GetObject("LDAP://" & CreateObject("ADSystemInfo").UserName).Mail
    End Sub

    • Marked as answer by George Hua Friday, November 15, 2013 3:58 PM
    Thursday, November 7, 2013 11:19 AM
  • Thanks Andreas

    How do I retrieve the address for a different parm other than username.  I need to feed in the string for which I need the email addy.

    Thanks

    Sean

    Thursday, November 7, 2013 10:53 PM
  • Have a look here, that is what I know:

    http://ss64.com/vb/syntax-userinfo.html

    http://ss64.com/vb/syntax-ad.html

    Andreas.


    Friday, November 8, 2013 11:06 AM