diff options
author | Dan Sledz <dsledz@isilon.com> | 2009-02-10 13:59:10 -0800 |
---|---|---|
committer | Steven Danneman <steven.danneman@isilon.com> | 2009-02-11 19:39:18 -0800 |
commit | 3b8a57e064250c6e46458e69ba156aa5d8c22059 (patch) | |
tree | 5c4bf7d17f8a4215e01302c692b4c3d578fc6341 /nsswitch/wbinfo.c | |
parent | aed8e9aa0a887e31562ac9da38ee4a878a4dd4ba (diff) | |
download | samba-3b8a57e064250c6e46458e69ba156aa5d8c22059.tar.gz |
s3: Implement wbcGetSidAliases
* Adds wbcGetSidAliases that calls the lookup_useraliases function.
* Updates wbinfo and winbind_util.c to call the new function.
* Also added winbind_get_groups helper function.
Diffstat (limited to 'nsswitch/wbinfo.c')
-rw-r--r-- | nsswitch/wbinfo.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c index 372896ce71b..4d935f52394 100644 --- a/nsswitch/wbinfo.c +++ b/nsswitch/wbinfo.c @@ -366,6 +366,64 @@ static bool wbinfo_get_userdomgroups(const char *user_sid_str) return true; } +static bool wbinfo_get_sidaliases(const char *domain, + const char *user_sid_str) +{ + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + struct wbcDomainInfo *dinfo = NULL; + uint32_t i; + struct wbcDomainSid user_sid; + uint32_t *alias_rids = NULL; + uint32_t num_alias_rids; + char *domain_sid_str = NULL; + + /* Send request */ + if ((domain == NULL) || (strequal(domain, ".")) || + (domain[0] == '\0')) { + domain = get_winbind_domain(); + } + + /* Send request */ + + wbc_status = wbcDomainInfo(domain, &dinfo); + if (!WBC_ERROR_IS_OK(wbc_status)) { + d_printf("wbcDomainInfo(%s) failed: %s\n", domain, + wbcErrorString(wbc_status)); + goto done; + } + wbc_status = wbcStringToSid(user_sid_str, &user_sid); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; + } + + wbc_status = wbcGetSidAliases(&dinfo->sid, &user_sid, 1, + &alias_rids, &num_alias_rids); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; + } + + wbc_status = wbcSidToString(&dinfo->sid, &domain_sid_str); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; + } + + for (i = 0; i < num_alias_rids; i++) { + d_printf("%s-%d\n", domain_sid_str, alias_rids[i]); + } + + wbcFreeMemory(alias_rids); + +done: + if (domain_sid_str) { + wbcFreeMemory(domain_sid_str); + } + if (dinfo) { + wbcFreeMemory(dinfo); + } + return (WBC_ERR_SUCCESS == wbc_status); +} + + /* Convert NetBIOS name to IP */ static bool wbinfo_wins_byname(const char *name) @@ -1578,6 +1636,7 @@ enum { OPT_GETDCNAME, OPT_DSGETDCNAME, OPT_USERDOMGROUPS, + OPT_SIDALIASES, OPT_USERSIDS, OPT_ALLOCATE_UID, OPT_ALLOCATE_GID, @@ -1653,6 +1712,7 @@ int main(int argc, char **argv, char **envp) { "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r', "Get user groups", "USER" }, { "user-domgroups", 0, POPT_ARG_STRING, &string_arg, OPT_USERDOMGROUPS, "Get user domain groups", "SID" }, + { "sid-aliases", 0, POPT_ARG_STRING, &string_arg, OPT_SIDALIASES, "Get sid aliases", "SID" }, { "user-sids", 0, POPT_ARG_STRING, &string_arg, OPT_USERSIDS, "Get user group sids for user SID", "SID" }, { "authenticate", 'a', POPT_ARG_STRING, &string_arg, 'a', "authenticate user", "user%password" }, { "set-auth-user", 0, POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" }, @@ -1936,6 +1996,13 @@ int main(int argc, char **argv, char **envp) goto done; } break; + case OPT_SIDALIASES: + if (!wbinfo_get_sidaliases(opt_domain_name, string_arg)) { + d_fprintf(stderr, "Could not get sid aliases " + "for user SID %s\n", string_arg); + goto done; + } + break; case 'a': { bool got_error = false; |