dsquery remote AD server

8,573

dsquery server is for finding server instances, not connecting to a server - there's no session or setting persistence from one run of dsquery to another.

To do this query against a specific server, this would be the syntax:

dsquery user -name <username> -s <servername>

However, this is a query against the user's name, not their account name (unsure of whether it's looking at the displayName, cn, or some other attribute) - to query against a user's account name this would be the query to use:

dsquery user -samid <username> -s <servername>
Share:
8,573

Related videos on Youtube

Fuchida
Author by

Fuchida

OS: Ubuntu Linux &amp; Windows Language: Python Thoughts: blog.fuchida.me Code: github.com/fuchida

Updated on September 18, 2022

Comments

  • Fuchida
    Fuchida almost 2 years

    Im attempting to do a dsquery on a remoter AD server that I have access to through my network(No UN and PASS required).

    dsquery server -s <server name> is supposed to connect me to a server while dsquery user -name <username> is supposed to search for a certain user.

    I attempted to combine the two with "&&" but it just get a list of LDAP object.

    Is what I'm trying to do even possible ? I've searched but do not seem to find anything on the matter

  • Fuchida
    Fuchida over 12 years
    The syntax seems to be correct as I do not get an error but on the other hand I do not get a result. I found a user in AD UI but when I do the search in CMD a get no result. So I'm assuming there is an issue on my end rather than the syntax/dsquery...
  • ravi yarlagadda
    ravi yarlagadda over 12 years
    Are you looking for the user's full name or the account name? -name looks at the full name, -samid username might be what you need instead.
  • Fuchida
    Fuchida over 12 years
    when I user the same search format for my local domain I get a result. so dsquery user -name <username> -s <local servername> server returns a result while dsquery user -name <username> -s <remote servername> does not
  • ravi yarlagadda
    ravi yarlagadda over 12 years
    Are both of those systems domain controllers? On the same domain?
  • Fuchida
    Fuchida over 12 years
    your first comment fixed my issue. MUCH appreciated !. How do I make your comment as the answer ? Can you paste what you explained in the answer box so I can mark it as the answer or do I mark the original ? Im guessing the original is valid
  • ravi yarlagadda
    ravi yarlagadda over 12 years
    Great! I'll edit the answer with the additional information.
  • Fuchida
    Fuchida over 12 years
    Sounds good ! I marked the answer as correct and thanks again