static bool wbinfo_uid_to_sid(uid_t uid) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct wbcDomainSid sid; char *sid_str = NULL; /* Send request */ wbc_status = wbcUidToSid(uid, &sid); if (!WBC_ERROR_IS_OK(wbc_status)) { return false; } wbc_status = wbcSidToString(&sid, &sid_str); if (!WBC_ERROR_IS_OK(wbc_status)) { return false; } /* Display response */ d_printf("%s\n", sid_str); wbcFreeMemory(sid_str); return true; }
wbcErr wbcUnixIdsToSids(const struct wbcUnixId *ids, uint32_t num_ids, struct wbcDomainSid *sids) { size_t c; wbcErr wbc_status; for (c = 0; c < num_ids; c++) { switch (ids[c].type) { case WBC_ID_TYPE_UID: wbc_status = wbcUidToSid(ids[c].id.uid, &sids[c]); break; case WBC_ID_TYPE_GID: wbc_status = wbcGidToSid(ids[c].id.gid, &sids[c]); break; default: wbc_status = WBC_ERR_INVALID_PARAM; } if (!WBC_ERROR_IS_OK(wbc_status)) { sids[c] = (struct wbcDomainSid){ 0 }; }; } return WBC_ERR_SUCCESS; }
static NTSTATUS lwi_get_sid_from_id(struct idmap_domain *dom, struct id_map **ids) { int i; NTSTATUS nt_status = NT_STATUS_NONE_MAPPED; /* loop over the array and issue requests one at a time */ for (i = 0; ids[i]; i++) { struct wbcDomainSid wbc_sid; wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; ids[i]->status = ID_UNMAPPED; switch (ids[i]->xid.type) { case ID_TYPE_UID: wbc_status = wbcUidToSid(ids[i]->xid.id, &wbc_sid); break; case ID_TYPE_GID: wbc_status = wbcGidToSid(ids[i]->xid.id, &wbc_sid); break; default: return NT_STATUS_INVALID_PARAMETER; } if (WBC_ERROR_IS_OK(wbc_status)) { memcpy(ids[i]->sid, &wbc_sid, sizeof(*ids[i]->sid)); ids[i]->status = ID_MAPPED; nt_status = NT_STATUS_OK; } } return nt_status; }
bool winbind_uid_to_sid(struct dom_sid *sid, uid_t uid) { struct wbcDomainSid dom_sid; wbcErr result; result = wbcUidToSid(uid, &dom_sid); if (result == WBC_ERR_SUCCESS) { memcpy(sid, &dom_sid, sizeof(struct dom_sid)); } else { sid_copy(sid, &global_sid_NULL); } return (result == WBC_ERR_SUCCESS); }