Skip navigation

Q. How can I use Dsquery and Dsget to get an object's SID?

A. Dsquery can output many object attributes, including the SID (objectSID). The easiest way is to use a filter query to show the objectsid attribute, as in the following example:

dsquery * -filter "&(objectcategory=user)(samaccountname=john)" -attr objectsid

The return is:

objectsid S-1-5-21-2835294230-785241407-2532694646-1106

You can also use Dsget to get the distinguished name (DN), like the following example:

dsget user "cn=john savill,cn=users,dc=savilltech,dc=net" -sid

The return would be:

sid S-1-5-21-2835294230-785241407-2532694646-1106 dsget succeeded

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish