Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 1 down vote accepted

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|improve this answer
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... – Fuchida Dec 16 '11 at 19:00
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. – Shane Madden Dec 16 '11 at 19:02
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 – Fuchida Dec 16 '11 at 19:02
Are both of those systems domain controllers? On the same domain? – Shane Madden Dec 16 '11 at 19:03
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 – Fuchida Dec 16 '11 at 19:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.