Announcement

Collapse
No announcement yet.

Export Distinguished Name of a specfic user

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Export Distinguished Name of a specfic user

    Hello all,
    I am requiring your assistance once again.
    i need to export a user's Distinguished Name.

    Until now the only way i can do it is by running the following dsquery:

    dsquery user "OU=test,DC=work,DC=com" -name <Enter LAST NAME>* > C:\results.txt

    The query above lets me run a query using a user's last name in a specific OU.
    However it's not as professional and accurate as i'd like (having to edit the file every time, and it may end up giving 2 or more results)

    i am looking for a more specific query or a vbs script that will first ask me for a username and will output it's Distinguished Name.

    any help would be greatly appreciated.
    thank you.

  • #2
    Re: Export Distinguished Name of a specfic user

    Originally posted by Johnny.Jonathan View Post
    it may end up giving 2 or more results)

    i am looking for a more specific query or a vbs script that will first ask me for a username and will output it's Distinguished Name.
    You won't need VBScript, batch files work too. Save this code snippet as "getuser.cmd" or whatever and try it like this: getuser joeuser* This will execute the batch file and pass joeuser* as a parameter to the dsquery command.

    Code:
    ::BOF
    dsquery user "OU=test,DC=work,DC=com" -limit 1 -name %1 > c:\results.txt
    ::EOF
    If you really insist on a Vbs script, I guess I could write one.

    As for returning multiple hits, the -limit 1 switch will limit the output to single a hit. Then again, if you have users named Joeuser1, Joeuser2 and Joeuser3, which one do you expect to get when you run dsquery user "OU=test,DC=work,DC=com" -name joeuser* anyway? Simply put, the wildcard usage might return more than one hit, and you got to deal with it. Either by limiting the query or providing ways to handle multiple results. Maybe user names should be more different? Maybe you could tweak the business case somehow in order to get more a detailed data about which user you want to dsquery.

    -vP

    Comment


    • #3
      Re: Export Distinguished Name of a specfic user

      In vbs you can use the InputBox() function that displays a dialog box where the name of a user can be entered. Then use a NameTranslation method to convert it to a DN format of that user.

      \Rems

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment

      Working...
      X