[s3]winbindd_util: add fill_domain_username_talloc().
authorMichael Adam <obnox@samba.org>
Mon, 22 Sep 2008 08:37:11 +0000 (10:37 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 23 Sep 2008 08:00:26 +0000 (10:00 +0200)
A talloc version of fill_domain_username().

Michael

source3/winbindd/winbindd_util.c

index b296465ed54eee25a88236d71c0941ecab8cc59a..5b5ca41a745322ae59a115b73016564e7801470a 100644 (file)
@@ -1213,6 +1213,33 @@ void fill_domain_username(fstring name, const char *domain, const char *user, bo
        }
 }
 
+/**
+ * talloc version of fill_domain_username()
+ * return NULL on talloc failure.
+ */
+char *fill_domain_username_talloc(TALLOC_CTX *mem_ctx,
+                                 const char *domain,
+                                 const char *user,
+                                 bool can_assume)
+{
+       char *tmp_user, *name;
+
+       tmp_user = talloc_strdup(mem_ctx, user);
+       strlower_m(tmp_user);
+
+       if (can_assume && assume_domain(domain)) {
+               name = tmp_user;
+       } else {
+               name = talloc_asprintf(mem_ctx, "%s%c%s",
+                                      domain,
+                                      *lp_winbind_separator(),
+                                      tmp_user);
+               TALLOC_FREE(tmp_user);
+       }
+
+       return name;
+}
+
 /*
  * Winbindd socket accessor functions
  */