Results 1 to 3 of 3

Thread: ADSI - User Context

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    ADSI - User Context

    Does anyone know how to use VBSCript (maybe using ADSI or LDAP) to get the context that the current logged in user is in? In other words, I know how to get the logged in users username, but I need to know where that username resides in Active Directory.

    Thanks

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Anyone?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    Resolved!!

    Syntax:

    Dim nto
    const ADS_NAME_INITTYPE_SERVER = 2
    const ADS_NAME_INITTYPE_DOMAIN = 1
    const ADS_NAME_TYPE_1779 = 1
    const ADS_NAME_TYPE_NT4 = 3

    Set objNetwork = CreateObject("WScript.Network")

    Do While strUser = ""
    strUser = objNetwork.UserName
    WScript.Sleep 100
    Loop

    dn = "DSHS\" & strUser
    Set nto = CreateObject("NameTranslate")
    nto.Init ADS_NAME_INITTYPE_DOMAIN, "YourDomain"
    nto.Set ADS_NAME_TYPE_NT4, dn
    result_ldap = nto.Get(ADS_NAME_TYPE_1779)

    WScript.Echo "Translated name: " & result_ldap

Posting Permissions

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



Click Here to Expand Forum to Full Width