diff options
author | Rob Crittenden <rcritten@redhat.com> | 2012-05-24 13:52:07 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-05-25 09:49:06 +0200 |
commit | 74293426d9b88dad1fffa1762d2be83b1eb45d02 (patch) | |
tree | d7b55947dd2d795a6693204f08d7107a2f5b3225 /daemons/ipa-slapi-plugins/ipa-winsync | |
parent | b26777c59d9c4442b0c9cd45a29a56d9f8236c2d (diff) | |
download | freeipa-74293426d9b88dad1fffa1762d2be83b1eb45d02.tar.gz freeipa-74293426d9b88dad1fffa1762d2be83b1eb45d02.tar.xz freeipa-74293426d9b88dad1fffa1762d2be83b1eb45d02.zip |
Normalize uid to lower case in winsync.
This in effect fixes uid, krbPrincipalName and homeDir.
https://fedorahosted.org/freeipa/ticket/2756
Diffstat (limited to 'daemons/ipa-slapi-plugins/ipa-winsync')
-rw-r--r-- | daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c index ef237e93a..5d9e3cf94 100644 --- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c +++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c @@ -61,6 +61,7 @@ #include <string.h> #include <stdlib.h> +#include <ctype.h> #include "plstr.h" static void @@ -82,6 +83,25 @@ do_force_sync( int *do_modify /* set to true if mods were applied */ ); +static char * +str_tolower(char *str) +{ + char *lstr, *t; + + lstr = strdup(str); + if (!lstr) { + /* the caller should log OOM if this returns NULL */ + return NULL; + } + + for (t = lstr; *t; t++) + if (isalpha(*t)) + *t = tolower(*t); + + return lstr; +} + + /* This is called when a new agreement is created or loaded at startup. */ @@ -278,11 +298,22 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry, if (slapi_entry_attr_find(ds_entry, type, &e_attr) || !e_attr) { char *upn = NULL; char *uid = NULL; + char *lower = NULL; char *samAccountName = NULL; /* if the ds_entry already has a uid, use that */ if ((uid = slapi_entry_attr_get_charptr(ds_entry, "uid"))) { - upn = slapi_ch_smprintf("%s@%s", uid, ipaconfig->realm_name); + lower = str_tolower(uid); + if (!lower) { + LOG_OOM(); + return; + } + /* Now reset UID to be lower-case */ slapi_ch_free_string(&uid); + slapi_entry_attr_delete(ds_entry, "uid"); + slapi_entry_attr_set_charptr(ds_entry, "uid", lower); + /* And create a normalized principal */ + upn = slapi_ch_smprintf("%s@%s", lower, ipaconfig->realm_name); + free(lower); /* otherwise, use the samAccountName from the ad_entry */ } else if ((samAccountName = slapi_entry_attr_get_charptr(ad_entry, "samAccountName"))) { |