dsquery remote AD server
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 videos on Youtube
![Fuchida](https://i.stack.imgur.com/kP5GW.png?s=256&g=1)
Fuchida
OS: Ubuntu Linux & Windows Language: Python Thoughts: blog.fuchida.me Code: github.com/fuchida
Updated on September 18, 2022Comments
-
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 whiledsquery 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 over 12 yearsThe 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 over 12 yearsAre 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 over 12 yearswhen 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 over 12 yearsAre both of those systems domain controllers? On the same domain?
-
Fuchida over 12 yearsyour 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 over 12 yearsGreat! I'll edit the answer with the additional information.
-
Fuchida over 12 yearsSounds good ! I marked the answer as correct and thanks again