/* convert a SID to a string, either numeric or username/group */ static void SidToString(fstring str, DOM_SID *sid) { char **domains = NULL; char **names = NULL; uint32 *types = NULL; sid_to_string(str, sid); if (numeric) return; if (strcmp(str, "S-1-1-0") == 0) { fstrcpy(str, "everyone"); return; } /* Ask LSA to convert the sid to a name */ if (!cacls_open_policy_hnd() || !NT_STATUS_IS_OK(cli_lsa_lookup_sids(&lsa_cli, lsa_cli.mem_ctx, &pol, 1, sid, &domains, &names, &types)) || !domains || !domains[0] || !names || !names[0]) { return; } /* Converted OK */ slprintf(str, sizeof(fstring) - 1, "%s%s%s", domains[0], lp_winbind_separator(), names[0]); }
/* convert a string to a SID, either numeric or username/group */ static BOOL StringToSid(DOM_SID *sid, const char *str) { uint32 *types = NULL; DOM_SID *sids = NULL; BOOL result = True; if (strncmp(str, "S-", 2) == 0) { return string_to_sid(sid, str); } if (!cacls_open_policy_hnd() || !NT_STATUS_IS_OK(cli_lsa_lookup_names(global_hack_cli, global_hack_cli->mem_ctx, &pol, 1, &str, &sids, &types))) { result = False; goto done; } sid_copy(sid, &sids[0]); done: return result; }