summaryrefslogtreecommitdiff
path: root/source3/winbindd/idmap_ldap.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-06-17 20:19:46 +0200
committerMichael Adam <obnox@samba.org>2010-08-14 02:10:54 +0200
commit26c82596d95d31dc3d141656266123ca1fff8644 (patch)
treef8b2bcb780850527bbf42a8c775da734eb7ed7e2 /source3/winbindd/idmap_ldap.c
parent4ed6f315d93213154a39748c4ecc68d3d51df488 (diff)
downloadsamba-26c82596d95d31dc3d141656266123ca1fff8644.tar.gz
samba-26c82596d95d31dc3d141656266123ca1fff8644.tar.bz2
samba-26c82596d95d31dc3d141656266123ca1fff8644.zip
s3:idmap_ldap: add a idmap_ldap_new_mapping().
High level function to create a new mapping for an unmapped sid. This builds logic that used to reside in the top level idmap code in the backend.
Diffstat (limited to 'source3/winbindd/idmap_ldap.c')
-rw-r--r--source3/winbindd/idmap_ldap.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c
index 1079de1e1d..be1169d757 100644
--- a/source3/winbindd/idmap_ldap.c
+++ b/source3/winbindd/idmap_ldap.c
@@ -750,6 +750,54 @@ done:
return ret;
}
+/**
+ * Create a new mapping for an unmapped SID, also allocating a new ID.
+ * If possible, this should be run inside a transaction to make the
+ * action atomic.
+ */
+static NTSTATUS idmap_ldap_new_mapping(struct idmap_domain *dom, struct id_map *map)
+{
+ NTSTATUS ret;
+
+ if (map == NULL) {
+ ret = NT_STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+
+ if ((map->xid.type != ID_TYPE_UID) && (map->xid.type != ID_TYPE_GID)) {
+ ret = NT_STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+
+ if (map->sid == NULL) {
+ ret = NT_STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+
+ ret = idmap_ldap_get_new_id(dom, &map->xid);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(3, ("Could not allocate id: %s\n", nt_errstr(ret)));
+ goto done;
+ }
+
+ DEBUG(10, ("Setting mapping: %s <-> %s %lu\n",
+ sid_string_dbg(map->sid),
+ (map->xid.type == ID_TYPE_UID) ? "UID" : "GID",
+ (unsigned long)map->xid.id));
+
+ map->status = ID_MAPPED;
+
+ /* store the mapping */
+ ret = idmap_ldap_set_mapping(dom, map);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(3, ("Could not store the new mapping: %s\n",
+ nt_errstr(ret)));
+ }
+
+done:
+ return ret;
+}
+
/* max number of ids requested per batch query */
#define IDMAP_LDAP_MAX_IDS 30