s3: To correctly handle upn
authorBo Yang <boyang@samba.org>
Thu, 23 Jul 2009 02:23:21 +0000 (10:23 +0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 27 Jul 2009 10:09:57 +0000 (12:09 +0200)
lookupname failed, cannot find domain when attempt
to change password.

This addresses bug #6560.

Signed-off-by: Bo Yang <boyang@samba.org>
nsswitch/pam_winbind.c
source3/winbindd/winbindd_sid.c
source3/winbindd/winbindd_util.c

index e90f1b75ad63973e1dcca996ef97b30cc78f5727..4a44248e8ea90604c6a25398f76265608ff6a196 100644 (file)
@@ -2284,6 +2284,7 @@ static char* winbind_upn_to_username(struct pwb_context *ctx,
        enum wbcSidType type;
        char *domain;
        char *name;
+       char *p;
 
        /* This cannot work when the winbind separator = @ */
 
@@ -2292,9 +2293,19 @@ static char* winbind_upn_to_username(struct pwb_context *ctx,
                return NULL;
        }
 
+       name = talloc_strdup(ctx, upn);
+       if (!name) {
+               return NULL;
+       }
+
+       if ((p = strchr(name, '@')) != NULL) {
+               *p = 0;
+               domain = p + 1;
+       }
+
        /* Convert the UPN to a SID */
 
-       wbc_status = wbcLookupName("", upn, &sid, &type);
+       wbc_status = wbcLookupName(domain, name, &sid, &type);
        if (!WBC_ERROR_IS_OK(wbc_status)) {
                return NULL;
        }
index 641b18ebbd8fbdd7ba31ca05738261374d4ed285..b0f2c72ae1e1b4379eba208abc2ef506b10dd434 100644 (file)
@@ -93,6 +93,11 @@ void winbindd_lookupname(struct winbindd_cli_state *state)
                *p = 0;
                name_domain = state->request.data.name.name;
                name_user = p+1;
+       } else if ((p = strchr(state->request.data.name.name, '@')) != NULL) {
+               /* upn */
+               name_domain = p + 1;
+               *p = 0;
+               name_user = state->request.data.name.name;
        } else {
                name_domain = state->request.data.name.dom_name;
                name_user = state->request.data.name.name;
index a2c1c85e0b357b4537123643f4fc231e7e07e502..3070c6297a4217d5f545a4e7a651c0feffef0f47 100644 (file)
@@ -1144,7 +1144,8 @@ bool parse_domain_user(const char *domuser, fstring domain, fstring user)
                if ( assume_domain(lp_workgroup())) {
                        fstrcpy(domain, lp_workgroup());
                } else if ((p = strchr(domuser, '@')) != NULL) {
-                       fstrcpy(domain, "");                    
+                       fstrcpy(domain, p + 1);
+                       user[PTR_DIFF(p, domuser)] = 0;
                } else {
                        return False;
                }