summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-11-14 20:12:42 +0100
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-11-15 14:26:40 +0100
commitda3d471d10a822713fea937b3e1951bdbdc7dc83 (patch)
tree9f67ef6c5a5525b20fc82441ad05cd06d2cfd3d4 /source4
parentbf4e8ba0485ca36a0a9db48d4cd7f133b848f1d4 (diff)
downloadsamba-da3d471d10a822713fea937b3e1951bdbdc7dc83.tar.gz
samba-da3d471d10a822713fea937b3e1951bdbdc7dc83.tar.bz2
samba-da3d471d10a822713fea937b3e1951bdbdc7dc83.zip
s4:samdb util - add a call for generating a correct "lDAPDisplayName"
This is needed for the SAMLDB module enhancement regarding schema objects. The algorithm in pseudo code is located in MS-ADTS 3.1.1.2.3.4.
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/common/util.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index dcbb462e71..4175928c50 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -37,6 +37,7 @@
#include "param/param.h"
#include "libcli/auth/libcli_auth.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "system/locale.h"
/*
search the sam for the specified attributes in a specific domain, filter on
@@ -2617,3 +2618,30 @@ failed:
talloc_free(tmp_ctx);
return LDB_ERR_NO_SUCH_OBJECT;
}
+
+/*
+ * Function which generates a "lDAPDisplayName" attribute from a "CN" one.
+ * Algorithm implemented according to MS-ADTS 3.1.1.2.3.4
+ */
+const char *samdb_cn_to_lDAPDisplayName(TALLOC_CTX *mem_ctx, const char *cn)
+{
+ char **tokens, *ret;
+ size_t i;
+
+ tokens = str_list_make(mem_ctx, cn, " -_");
+ if (tokens == NULL)
+ return NULL;
+
+ /* "tolower()" and "toupper()" should also work properly on 0x00 */
+ tokens[0][0] = tolower(tokens[0][0]);
+ for (i = 1; i < str_list_length((const char **)tokens); i++)
+ tokens[i][0] = toupper(tokens[i][0]);
+
+ ret = talloc_strdup(mem_ctx, tokens[0]);
+ for (i = 1; i < str_list_length((const char **)tokens); i++)
+ ret = talloc_asprintf_append_buffer(ret, "%s", tokens[i]);
+
+ talloc_free(tokens);
+
+ return ret;
+}