Announcement

Collapse
No announcement yet.

Get attribute for a user

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

  • Get attribute for a user

    Hi everybody, good morning (at least in my time zone =P)

    Once in a while I have to check for an attribute of a user that is not listed in the "propierties" of the user ni the AD console, so I have to go to ADSI Edit, manually look up for the user, and manually look up for that specific attribute.

    I assume that there should be a much better / faster way of doing this:

    "Look for user PETER and echo whatever shows in the `Age` attribute"

    I don't have a lot of experience in scripting but I was wondering if this could be done with dsget and filter? Do you think there's a better way?

    Of course the BEST thing would be a VBScript that asks you for the user's CN and then returns the result of the query in a dialog box, but I don't know VBScripting that much as to do that.

    Well thank you very much you all!

  • #2
    Re: Get attribute for a user

    Use dsquery for generic LDAP query. You can list a lot of the attributes by using -attr *. Like so,

    Code:
    dsquery * -filter "(&(objclass=user)(samaccountame=USERNAME))" -attr *
    You can replace the * with any attribute you wish to get a value for.

    -vP

    Comment


    • #3
      Re: Get attribute for a user

      Originally posted by vonPryz View Post
      Use dsquery for generic LDAP query. You can list a lot of the attributes by using -attr *. Like so,

      Code:
      dsquery * -filter "(&(objclass=user)(samaccountame=USERNAME))" -attr *
      You can replace the * with any attribute you wish to get a value for.

      -vP
      I tried with that but I got no results (not even an error). Nothing.

      Then I tried with:

      dsquery * "CN=USERNAME,OU=Users,OU=Accounts,DC=microsoft,DC= com" -attr employeeID
      And it worked!

      Comment


      • #4
        Re: Get attribute for a user

        Thank you for this, this helped me as well!

        Comment


        • #5
          Re: Get attribute for a user

          Depends exactly which attribute you are after but you may find that you can get it from my AD reporting tool, AD Info (I can't post a direct link because I don't have enough posts but if you just google "cjwdev ad info" you will find it). There is a completely free version available that will do everything most people need, the paid for version just allows for custom queries to be created and settings to be controlled via GPO.
          I made it as user friendly as possible and in the next version you will be able to run it from command line and also be able to query any LDAP attribute you like, so perhaps the next version will be of more use to you in this particular scenario.
          Software for IT Pros that I've written: http://www.cjwdev.co.uk/Software.html

          My blog: http://cjwdev.wordpress.com

          Comment

          Working...
          X