Announcement

Collapse
No announcement yet.

Query all objects for samAccountName

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

  • Query all objects for samAccountName

    Is it possible with 1 command (from a command line), to query an entire AD forest for any object (groups, users or anything else) with a specific samAccountName?
    Last edited by jsmith2113; 2nd June 2009, 22:11.

  • #2
    Re: Query all objects for samAccountName

    Is this a test?
    Easiest method would be using find within ADUC.

    If not something like ldifde maybe?
    http://support.microsoft.com/kb/555636
    cheers
    Andy

    Please read this before you post:


    Quis custodiet ipsos custodes?

    Comment


    • #3
      Re: Query all objects for samAccountName

      Originally posted by AndyJG247 View Post
      Is this a test?
      Easiest method would be using find within ADUC.

      If not something like ldifde maybe?
      http://support.microsoft.com/kb/555636

      Looking for command-line method.

      For example, this command would return a group with samid = "ABC123":

      dsquery group forestroot -samid ABC123

      and this command would return a user with samid = "ABC123":

      dsquery user forestroot -samid ABC123

      Looking for a command where user or group does not have to be specified and would return any object with samid = "ABC123" in the forest.

      Comment


      • #4
        Re: Query all objects for samAccountName

        Does #1 in that link work?
        cheers
        Andy

        Please read this before you post:


        Quis custodiet ipsos custodes?

        Comment


        • #5
          Re: Query all objects for samAccountName

          To query any object in the directory use a wildcard sign for the object type and use a generic LDAP query.
          Code:
          dsquery.exe * forestroot -limit 0 -filter "(&(sAMAccountname=123*))" -attr sAMAccountname /Q
          \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


          • #6
            Re: Query all objects for samAccountName

            Originally posted by Rems View Post
            To query any object in the directory use a wildcard sign for the object type and use a generic LDAP query.
            Code:
            dsquery.exe * forestroot -limit 0 -filter "(&(sAMAccountname=123*))" -attr sAMAccountname /Q
            \Rems

            Thank you Rems - That works perfectly.

            Comment

            Working...
            X