Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Querying Active Directory (Win 2k, Office 2k)

    Hi folks

    I found this section of script useful.. sourced from FreeVBCode.com
    My question is this ..
    How can I return information from AD based on input which is user intials ? Assume that a unique combo of initals is used .
    '==============================
    Set oRoot = GetObject("LDAP://rootDSE")
    'work in the default domain
    sDomain = oRoot.Get("defaultNamingContext")
    Set oDomain = GetObject("LDAP://" & sDomain)
    sBase = "<" & oDomain.ADsPath & ">"
    'Only get user name requested
    sFilter = "(&(objectCategory=person)(objectClass=user)(name= " _
    & LoginName & "))"
    ' ---------------------------------
    'can we modify the line above for user initials
    '---------------------------------

    sAttribs = "adsPath"
    sDepth = "subTree"

    sQuery = sBase & ";" & sFilter & ";" & sAttribs & ";" & sDepth

    conn.Open _
    "Data Source=Active Directory Provider;Provider=ADsDSOObject"

    Set rs = conn.Execute(sQuery
    '===========================

    Thanks in advance

    Geof

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Querying Active Directory (Win 2k, Office 2k)

    Hi Geof,
    As far as I know AD does not store user initials as an attribute type, so you would either need a translation table so that you can input user initials but actually look up user names, or you would need to parse the initials and do a search using something like:
    <pre>sFilter = "(&(objectCategory=person)(objectClass=user) _
    (&(name="& strInitial1 & "*)(sn="&strInitial2&"*))"</pre>

    assuming 2 initials in a unique combination.
    (Note: that's air code so I can't guarantee it's correct syntax!)
    HTH.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: Querying Active Directory (Win 2k, Office 2k)

    Thanks for the help Rory
    Will let you know how I get on

    Cheers
    Geof

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Querying Active Directory (Win 2k, Office 2k)

    "Air Code"
    I like that term. For compilation in the mind only. Output results will vary.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •