summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index d703670860..41c012ba34 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1247,3 +1247,23 @@ char *string_truncate(char *s, int length)
}
return s;
}
+
+/* Parse a string of the form DOMAIN/user into a domain and a user */
+
+void parse_domain_user(char *domuser, fstring domain, fstring user)
+{
+ char *p;
+ char *sep = lp_winbind_separator();
+ if (!sep) sep = "\\";
+ p = strchr(domuser,*sep);
+ if (!p) p = strchr(domuser,'\\');
+ if (!p) {
+ fstrcpy(domain,"");
+ fstrcpy(user, domuser);
+ return;
+ }
+
+ fstrcpy(user, p+1);
+ fstrcpy(domain, domuser);
+ domain[PTR_DIFF(p, domuser)] = 0;
+}