Windows – dsquery remote AD server

active-directoryldapwindows

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

Best Answer

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>
Related Topic