{"id":109872,"date":"2024-06-10T07:00:00","date_gmt":"2024-06-10T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=109872"},"modified":"2024-06-10T06:56:57","modified_gmt":"2024-06-10T13:56:57","slug":"20240610-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20240610-00\/?p=109872","title":{"rendered":"How do I get the name of a SID, and what does it mean when the conversion fails?"},"content":{"rendered":"<p>A customer had a file share, and they couldn&#8217;t figure out who has access to some of the files. They pulled the access control list (ACL), extracted the security IDs (SIDs), <a title=\"How do I convert a SID between binary and string forms?\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040315-00\/?p=40253\"> converted them from binary to string form<\/a>, and the result was <tt>S-1-5-21-2127521184-1604012920-1887927527-72713<\/tt>. &#8220;Why didn&#8217;t the conversion work?&#8221;<\/p>\n<p>This is a rather confusing question, because the conversion did work. You have the answer: It&#8217;s <tt>S-1-5-21-2127521184-1604012920-1887927527-72713<\/tt>.<\/p>\n<p>After some back-and-forth we learned that what the customer really meant was &#8220;How can we take this SID and convert it to something semantically meaningful to humans, like a person&#8217;s name?&#8221;\u00b9<\/p>\n<p>Programmatically, you can use <code>LsaLookupSids2<\/code> to ask the local system to find a friendly name for a SID. It will consult its local account database, the domain&#8217;s account database, and maybe some other stuff. But sometimes it just shrugs its shoulders and says, &#8220;Sorry, I can&#8217;t come up with a better name for this one.&#8221;<\/p>\n<p>The customer was confused by the possibility of a SID with no known name. How can the security system work if it doesn&#8217;t know who a SID represents?<\/p>\n<p>The security system doesn&#8217;t care <i>who<\/i> a SID represents. When somebody tries to access a resource, it looks for matches between that person&#8217;s SIDs and the SIDs in the ACL, and follows the instructions associated with those matches. For example, there may be an access control entry (ACE) that says &#8220;Allow <tt>S-1-5-21-2127521184-1604012920-1887927527-72713<\/tt> to have read-only access.&#8221; The security system doesn&#8217;t know or care who <tt>S-1-5-21-2127521184-1604012920-1887927527-72713<\/tt> is.<\/p>\n<p>By analogy, suppose your IT department locks down your phone by pushing a list of phone numbers from whom it will accept calls. The phone doesn&#8217;t know the names of the callers, but it doesn&#8217;t need to know. It just takes every incoming phone call and sees if the number is on the &#8220;Allow&#8221; list. (This also avoids problems if somebody calls who happens to have the same name as a person on your allow list. Since the phone number doesn&#8217;t match, the call is not let through.) As a courtesy, your phone tries to find a name for the incoming call by looking in the phone&#8217;s contacts or maybe by contacting a service. But that is best effort, and sometimes you just get &#8220;Unknown caller&#8221;. Your phone doesn&#8217;t know who they are, but the phone doesn&#8217;t need to know who they are in order to make a block\/allow decision.<\/p>\n<p>You don&#8217;t know who this 555-1212 number is, but it&#8217;s on your Allow list. And you don&#8217;t know who this <tt>S-1-5-21-2127521184-1604012920-1887927527-72713<\/tt> SID is, but it&#8217;s there on the file&#8217;s Allow list.<\/p>\n<p>The customer said that they were using the Advanced Security Settings property sheet to look up the SIDs. That property sheet already uses <code>LsaLookupSids2<\/code> to look up friendly names for every SID, if known. If something shows up in <tt>S-...<\/tt> format, then it means that the system couldn&#8217;t find a friendly name.<\/p>\n<p>At this point, you need to follow the money backward. If you want to know who this 555-1212 number is, you can ask your IT administrator, since they are the ones who added that number to the Allow list. If you want to know who this <tt>S-1-5-21-2127521184-1604012920-1887927527-72713<\/tt> SID is, you can ask the file share owner or the file owner who it is. Presumably whoever put it on the access control list knows who it is. Otherwise, why would they have added it?<\/p>\n<p>\u00b9 It&#8217;s not clear to me how they expected the manual algorithm to produce something semantically meaningful, since the manual algorithm consists of counting things and inserting dashes. Nowhere in the algorithm does a number like &#8220;72713&#8221; turn into a name like &#8220;Chris&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most places will do it for you, or at least try.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25,104],"class_list":["post-109872","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>Most places will do it for you, or at least try.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/109872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=109872"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/109872\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=109872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=109872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=109872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}