summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/sdap.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-01-06 16:04:32 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-09 17:48:54 +0100
commitf8f2ec0b4097bef628e66919acb746fe0ef6f6c2 (patch)
treeb5baf93e3a8c506ea8d4a6bbcd12096873df0191 /src/providers/ldap/sdap.c
parent6e1c8bf0caadcd6749b142d8b0322bf320a48e7d (diff)
downloadsssd-f8f2ec0b4097bef628e66919acb746fe0ef6f6c2.tar.gz
sssd-f8f2ec0b4097bef628e66919acb746fe0ef6f6c2.tar.xz
sssd-f8f2ec0b4097bef628e66919acb746fe0ef6f6c2.zip
AD: replace GID/UID, do not add another one
The code would call sysdb_attrs_add_uint32 which added another UID or GID to the ID=0 we already downloaded from LDAP (0 is the default value) when ID-mapping an entry. This led to funky behaviour later on when we wanted to process the ID.
Diffstat (limited to 'src/providers/ldap/sdap.c')
-rw-r--r--src/providers/ldap/sdap.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index f5b1f95f0..371121b2c 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -1158,3 +1158,34 @@ int sdap_control_create(struct sdap_handle *sh, const char *oid, int iscritical,
return ret;
}
+
+int sdap_replace_id(struct sysdb_attrs *entry, const char *attr, id_t val)
+{
+ char *str;
+ errno_t ret;
+ struct ldb_message_element *el;
+
+ ret = sysdb_attrs_get_el_ext(entry, attr, false, &el);
+ if (ret == ENOENT) {
+ return sysdb_attrs_add_uint32(entry, attr, val);
+ } else if (ret) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Cannot get attribute [%s]\n", attr));
+ return ret;
+ }
+
+ if (el->num_values != 1) {
+ DEBUG(SSSDBG_OP_FAILURE,
+ ("Expected 1 value for %s, got %d\n", attr, el->num_values));
+ return EINVAL;
+ }
+
+ str = talloc_asprintf(entry, "%llu", (unsigned long long) val);
+ if (!str) {
+ return ENOMEM;
+ }
+
+ el->values[0].data = (uint8_t *) str;
+ el->values[0].length = strlen(str);
+
+ return EOK;
+}