Announcement

Collapse
No announcement yet.

how to find users distinguished name of users in AD?

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

  • how to find users distinguished name of users in AD?

    hey everyone,
    i exported the enabled user list from AD with LDAP query, but i need each user's distinguished name for moving into a new Network and creating all these users in my new AD.
    i have 390 users so i realy need some help!!!
    M3HDX
    ---------------
    MCSA/MCSE/MCTS
    Security+

  • #2
    Re: how to find users distinguished name of users in AD?

    "dsquery user > c:\dn.txt"

    Comment


    • #3
      Re: how to find users distinguished name of users in AD?

      yes you can use dsquery (help: dsquery.exe /?)

      To filter all disabled users out..
      copy the ldap-filter string from your 'saved query' and use it with dsquery -filter:
      Code:
      DSQUERY.exe * -limit 0 -filter "(&(objectCategory=Person)(objectClass=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))" >"c:\activeUsers.txt"
      \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


      • #4
        Re: how to find users distinguished name of users in AD?

        This one has worked for me just fine:

        Code:
        dsquery user -limit 1000 | dsget user -dn >C:\Getuserdn.txt
        Since you only have 390 users I'd leave the limit as it is otherwise replace with the right value.

        Cheers
        Caesar's cipher - 3

        ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

        SFX JNRS FC U6 MNGR

        Comment


        • #5
          Re: how to find users distinguished name of users in AD?

          Originally posted by L4ndy View Post
          This one has worked for me just fine:

          Code:
          dsquery user -limit 1000 | dsget user -dn >C:\Getuserdn.txt
          This will return ALL the user accounts including disabled accounts.
          Guy Teverovsky
          http://blogs.technet.com/b/isrpfeplat/
          "Smith & Wesson - the original point and click interface"

          Comment


          • #6
            Re: how to find users distinguished name of users in AD?

            Originally posted by guyt View Post
            This will return ALL the user accounts including disabled accounts.
            Yeah, you right, completely missed that bit.
            Plus looking at it more in depth at my code you dont even need to Pipe it to Dsget if the output it's going to be a txt file.
            So REMS suggestion should do just fine. ( Not that I was ever in doubt but I wasn't getting it!)

            Thanks
            Caesar's cipher - 3

            ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

            SFX JNRS FC U6 MNGR

            Comment


            • #7
              Re: how to find users distinguished name of users in AD?

              However, you could avoid doing the LDAP query step altogether if you run the following command against AD:
              Code:
              dsquery user -limit 0 | dsget user -dn -disabled >C:\getalluserdn.txt
              It'll create a file with all te users DN on it together with the Disabled status.
              The -Disabled parameter will return a value of Yes and No.
              You can then export the file into Excel and select only the records with a No value.
              You can then use the selected data to go to the next step of using DSadd user if you plan to have the same Ou structure in your new AD.

              Cheers
              Caesar's cipher - 3

              ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

              SFX JNRS FC U6 MNGR

              Comment


              • #8
                Re: how to find users distinguished name of users in AD?

                Thanks alot guys
                it Works fine for me Rems thank u !
                M3HDX
                ---------------
                MCSA/MCSE/MCTS
                Security+

                Comment

                Working...
                X