From c4999c38d1f24612d1b59f13135d14d07bb88f4a Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Fri, 7 Nov 2014 21:33:36 +0100 Subject: [PATCH 3/7] LDAP: always store UUID if available Related to https://fedorahosted.org/sssd/ticket/2481 --- src/providers/ldap/sdap_async_groups.c | 20 ++++++++++++++++++++ src/providers/ldap/sdap_async_users.c | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c index a82d2aa..dc1b60d 100644 --- a/src/providers/ldap/sdap_async_groups.c +++ b/src/providers/ldap/sdap_async_groups.c @@ -511,6 +511,7 @@ static int sdap_save_group(TALLOC_CTX *memctx, bool posix_group; bool use_id_mapping; char *sid_str; + const char *uuid; struct sss_domain_info *subdomain; int32_t ad_group_type; @@ -547,6 +548,25 @@ static int sdap_save_group(TALLOC_CTX *memctx, sid_str = NULL; } + /* Always store UUID if available */ + ret = sysdb_attrs_get_string(attrs, + opts->group_map[SDAP_AT_GROUP_UUID].sys_name, + &uuid); + if (ret == EOK) { + ret = sysdb_attrs_add_string(group_attrs, SYSDB_UUID, uuid); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, "Could not add UUID string: [%s]\n", + strerror(ret)); + goto done; + } + } else if (ret == ENOENT) { + DEBUG(SSSDBG_TRACE_ALL, "UUID not available for group [%s].\n", + group_name); + } else { + DEBUG(SSSDBG_MINOR_FAILURE, "Could not identify UUID [%s]\n", + strerror(ret)); + } + /* If this object has a SID available, we will determine the correct * domain by its SID. */ if (sid_str != NULL) { diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c index 2331ba9..c6da5c1 100644 --- a/src/providers/ldap/sdap_async_users.c +++ b/src/providers/ldap/sdap_async_users.c @@ -140,6 +140,7 @@ int sdap_save_user(TALLOC_CTX *memctx, TALLOC_CTX *tmpctx = NULL; bool use_id_mapping; char *sid_str; + const char *uuid; char *dom_sid_str = NULL; struct sss_domain_info *subdomain; @@ -177,6 +178,24 @@ int sdap_save_user(TALLOC_CTX *memctx, sid_str = NULL; } + /* Always store UUID if available */ + ret = sysdb_attrs_get_string(attrs, + opts->user_map[SDAP_AT_USER_UUID].sys_name, + &uuid); + if (ret == EOK) { + ret = sysdb_attrs_add_string(user_attrs, SYSDB_UUID, uuid); + if (ret != EOK) { + DEBUG(SSSDBG_MINOR_FAILURE, "Could not add UUID string: [%s]\n", + strerror(ret)); + goto done; + } + } else if (ret == ENOENT) { + DEBUG(SSSDBG_TRACE_ALL, "UUID not available for user.\n"); + } else { + DEBUG(SSSDBG_MINOR_FAILURE, "Could not identify UUID [%s]\n", + strerror(ret)); + } + /* If this object has a SID available, we will determine the correct * domain by its SID. */ if (sid_str != NULL) { -- 1.8.3.1