AD from CLI

Discussion in 'Active Directory Exams' started by Fergal1982, Aug 12, 2005.

  1. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    Ok guys,

    i do a decent amount of work on AD from my PC (things like password resets, adding users to groups, etc) and want to know how to do these things from the CLI if possible. What im looking at doing from CLI are:

    checking current groups of a named user
    adding a user to a new group
    searching for a group (like you can in the GUI AD)
    password resets
    searching for a user
    unlocking an account

    we also have multiple DC's, so i would like to be able to connect to the DC directly before running these commands.

    Thanks
    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  2. Phoenix
    Honorary Member

    Phoenix 53656e696f7220 4d6f64

    5,749
    200
    246
    checking current groups of a named user
    - dsget user "CN=Ryan Coates,CN=Users,DC=godlike,DC=Com" -memberof
    adding a user to a new group
    - dsmod group "CN=Domain Admins,CN=Users,DC=godlike,DC=Com" -addmbr "CN=Ryan Coates,CN=Users,DC=godlike,DC=Com"
    searching for a group (like you can in the GUI AD)
    - dsquery group -name Domain*
    password resets
    - dsmod user "CN=Ryan Coates,CN=Users,DC=godlike,DC=Com" -pwd l0s3r -mustchpwd yes
    searching for a user
    - dsquery user -name Ryan*
    unlocking an account
    - dsmod user "CN=Ryan Coates,CN=Users,DC=godlike,DC=Com" -disabled no

    A better way to do all that is pipe it all through the dsquery command so you dont have to use the full DN for most of those
    like say changing a passowrd

    - dsquery user -name Ryan*
    if that returns only one result press UP to get your history back and add to it
    - dsquery user -name Ryan* | dsmod user -pwd l0s3r -mustchpwd yes

    Check out these links for more detailed use of these tools
    DSMod
    DSQuery
    DSGet
     
    Certifications: MCSE, MCITP, VCP
    WIP: > 0
  3. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    cool, thanks - do they need to be run via telnet?
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  4. Phoenix
    Honorary Member

    Phoenix 53656e696f7220 4d6f64

    5,749
    200
    246
    sorry forgot to add that part

    this assumes you have the Admin pack installed onto your local machine

    otherwise you will indeed have to be attached to a machine that does either via telnet, ssh, or just opening up a cmd prompt via a remote desktop process

    by far the easiest way is to install the adminpak on your machine

    you can also parse these tools into scripts i believe
     
    Certifications: MCSE, MCITP, VCP
    WIP: > 0
  5. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    that will be whats stopping me then. no admin pack
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  6. AJ

    AJ 01000001 01100100 01101101 01101001 01101110 Administrator

    6,897
    182
    221
    Certifications: MCSE, MCSA (messaging), ITIL Foundation v3
    WIP: Breathing in and out, but not out and in, that's just wrong
  7. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    dammit. ive got adminpack installed, but they dont seem to be working. dsquery just comes back stating that it is an unrecognised command. (sigh)

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  8. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Just a thought, but sometimes it makes a difference what directory I'm in whether or not some commands will run. I don't know why that should be but it does work that way sometimes. If I cd to c:\ from something like c:\Documents and Settings\username the commands will run. It's always puzzled me as to why it does that because once something is installed in the system path it should just run from wherever I am in the directory structure.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  9. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    Nope. same error. That is a bit strange though - ive also tried it from the system32 folder (where the dll is kept)
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  10. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Have you checked the system path to see if by some odd chance system32 isn't in the path? If it isn't you might try adding it just to see what happens.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  11. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    but even if it wasnt - shouldnt it run when im sitting in the directory?
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  12. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    It should, but I've found that with Windows all things are possible.... :twisted:
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  13. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I did a little research into this and one thing I found that I discounted as very unlikely was that the 2003 admin pack won't run on an XP box that doesn't have at least SP1 installed. It's a very remote possibility, so remote I didn't bring it up at first, but are you running a pre-sp1 version of XP?
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  14. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    im currently sitting on win2k
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  15. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    There's your problem. The admin pack for server 2003 doesn't run on Win 2K. It only runs on XP and 2003.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  16. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    what a piece of pish! did they never consider that the server might be 2k3, but the users might be on 2k? muppets!
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  17. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    You bet they did. It's just another one of Microsoft's "sticks", as opposed to "carrots", in their marketing strategy. They're going to force you to upgrade your desktop just to administer your servers. They do a lot of stuff like this.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  18. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    it just so happens i will being refreshed soon (i hope). but still!
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  19. Phoenix
    Honorary Member

    Phoenix 53656e696f7220 4d6f64

    5,749
    200
    246
    err, also could be i made a mistake, it MIGHT be part or the win2k3 support tools which you install from the 2k3 CD, sorry :/ I have both installed and just assumed it was the adminpak

    if it HAD installed with the adminpak and just wasnt working due to an OS error, it would spit back an error, not a 'not found'
     
    Certifications: MCSE, MCITP, VCP
    WIP: > 0
  20. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    172
    211
    i think it is part of the admin pack - the tech guys here seem to think thats the case.

    Dont know.
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.