X-Git-Url: http://git.samba.org/samba.git/?p=ira%2Fwip.git;a=blobdiff_plain;f=source3%2Flib%2Fwinbind_util.c;h=686e70f4ad7860a17d3374f002f5e3756daffc27;hp=2cabf5bcacf45e5c7a43bd505c793c1160ba01d8;hb=aed8e9aa0a887e31562ac9da38ee4a878a4dd4ba;hpb=701a56a698b580b21bfb0df73401ffe2d05f6f19 diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c index 2cabf5bcacf..686e70f4ad7 100644 --- a/source3/lib/winbind_util.c +++ b/source3/lib/winbind_util.c @@ -24,6 +24,43 @@ #include "nsswitch/libwbclient/wbclient.h" +struct passwd * winbind_getpwnam(const char * name) +{ + wbcErr result; + struct passwd * tmp_pwd = NULL; + struct passwd * pwd = NULL; + + result = wbcGetpwnam(name, &tmp_pwd); + if (result != WBC_ERR_SUCCESS) + return pwd; + + pwd = tcopy_passwd(talloc_tos(), tmp_pwd); + + wbcFreeMemory(tmp_pwd); + + return pwd; +} + +struct passwd * winbind_getpwsid(const DOM_SID *sid) +{ + wbcErr result; + struct passwd * tmp_pwd = NULL; + struct passwd * pwd = NULL; + struct wbcDomainSid dom_sid; + + memcpy(&dom_sid, sid, sizeof(dom_sid)); + + result = wbcGetpwsid(&dom_sid, &tmp_pwd); + if (result != WBC_ERR_SUCCESS) + return pwd; + + pwd = tcopy_passwd(talloc_tos(), tmp_pwd); + + wbcFreeMemory(tmp_pwd); + + return pwd; +} + /* Call winbindd to convert a name to a sid */ bool winbind_lookup_name(const char *dom_name, const char *name, DOM_SID *sid, @@ -35,12 +72,12 @@ bool winbind_lookup_name(const char *dom_name, const char *name, DOM_SID *sid, result = wbcLookupName(dom_name, name, &dom_sid, &type); if (result != WBC_ERR_SUCCESS) - return False; + return false; memcpy(sid, &dom_sid, sizeof(DOM_SID)); *name_type = (enum lsa_SidType)type; - return True; + return true; } /* Call winbindd to convert sid to name */ @@ -59,7 +96,7 @@ bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, result = wbcLookupSid(&dom_sid, &domain_name, &account_name, &type); if (result != WBC_ERR_SUCCESS) - return False; + return false; /* Copy out result */ @@ -79,11 +116,11 @@ bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, if ((domain && !*domain) || (name && !*name)) { DEBUG(0,("winbind_lookup_sid: talloc() failed!\n")); - return False; + return false; } - return True; + return true; } /* Ping winbindd to see it is alive */ @@ -193,7 +230,7 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx, ret = wbcLookupRids(&dom_sid, num_rids, rids, &dom_name, &namelist, &name_types); if (ret != WBC_ERR_SUCCESS) { - return False; + return false; } *domain_name = talloc_strdup(mem_ctx, dom_name); @@ -201,7 +238,7 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx, *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids); for(i=0; i