none
How to get the name of the selected user in Active Directory. RRS feed

  • Question

  • Hi,

    I have added an vbs script to the Active Directory GUI, to do some actions on a selected user.

    When I right-click on a AD user, I choose my custom option, and a vbs script starts.

    So far so good, but in the script i would like to know the account (logonname) for that user.

    I can find many examples to do that with a script and a given parameter, but the parameter is in my case, the selected user in AD.

    Who can help ?

    Luc

    Wednesday, October 29, 2014 3:49 PM

Answers

  • You just need to take the arguments and echo out the samaccountname (or do something else with it) - 

    Set wshArgs=WScript.Arguments
    
    Set adsUser=GetObject(wshArgs(0))
    MsgBox adsUser.samaccountname


    • Edited by Braham20 Wednesday, October 29, 2014 4:17 PM
    • Marked as answer by LLV8530 Wednesday, October 29, 2014 4:19 PM
    Wednesday, October 29, 2014 4:16 PM

All replies

  • You just need to take the arguments and echo out the samaccountname (or do something else with it) - 

    Set wshArgs=WScript.Arguments
    
    Set adsUser=GetObject(wshArgs(0))
    MsgBox adsUser.samaccountname


    • Edited by Braham20 Wednesday, October 29, 2014 4:17 PM
    • Marked as answer by LLV8530 Wednesday, October 29, 2014 4:19 PM
    Wednesday, October 29, 2014 4:16 PM
  • Thanks a lot !
    Wednesday, October 29, 2014 4:19 PM