summaryrefslogtreecommitdiff
path: root/source3/sam/idmap_tdb.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-07-11 05:33:40 +0000
committerGerald Carter <jerry@samba.org>2003-07-11 05:33:40 +0000
commit03d5867d529f126da368ebda70bf2d997aa602e0 (patch)
tree6bed479ab42b3bcbd5ac6b70157c16232ff69869 /source3/sam/idmap_tdb.c
parentd117c83ca9fc1b598d09f5d24805560e9c49f65c (diff)
downloadsamba-03d5867d529f126da368ebda70bf2d997aa602e0.tar.gz
samba-03d5867d529f126da368ebda70bf2d997aa602e0.tar.bz2
samba-03d5867d529f126da368ebda70bf2d997aa602e0.zip
moving more code around.
* move rid allocation into IDMAP. See comments in _api_samr_create_user() * add winbind delete user/group functions I'm checking this in to sync up with everyone. But I'm going to split the add a separate winbindd_allocate_rid() function for systems that have an 'add user script' but need idmap to give them a RID. Life would be so much simplier without 'enable rid algorithm'. The current RID allocation is horrible due to this one fact. Tested idmap_tdb but not idmap_ldap yet. Will do that tomorrow. Nothing has changed in the way a samba domain is represented, stored, or search in the directory so things should be ok with previous installations. going to bed now. (This used to be commit 0463045cc7ff177fab44b25faffad5bf7140244d)
Diffstat (limited to 'source3/sam/idmap_tdb.c')
-rw-r--r--source3/sam/idmap_tdb.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/source3/sam/idmap_tdb.c b/source3/sam/idmap_tdb.c
index 4643b7db59..7f8dce1f1a 100644
--- a/source3/sam/idmap_tdb.c
+++ b/source3/sam/idmap_tdb.c
@@ -59,7 +59,45 @@ TDB_CONTEXT *idmap_tdb_handle( void )
return NULL;
}
-/* Allocate either a user or group id from the pool */
+/**********************************************************************
+ allocate a new RID; We don't care if is a user or group
+**********************************************************************/
+
+static NTSTATUS db_allocate_rid(uint32 *rid, int rid_type)
+{
+ uint32 lowrid, highrid;
+ uint32 tmp_rid;
+
+ /* can't handle group rids right now. This is such a mess.... */
+
+ if ( rid_type == GROUP_RID_TYPE )
+ return NT_STATUS_UNSUCCESSFUL;
+
+ /* cannot fail since idmap is only called winbindd */
+
+ idmap_get_free_rid_range( &lowrid, &highrid );
+
+ tmp_rid = lowrid;
+
+ if ( !tdb_change_uint32_atomic(idmap_tdb, "RID_COUNTER", &tmp_rid, RID_MULTIPLIER) ) {
+ DEBUG(3,("db_allocate_rid: Failed to locate next rid record in idmap db\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ if ( tmp_rid > highrid ) {
+ DEBUG(0, ("db_allocate_rid: no RIDs available!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ *rid = tmp_rid;
+
+ return NT_STATUS_OK;
+}
+
+/**********************************************************************
+ Allocate either a user or group id from the pool
+**********************************************************************/
+
static NTSTATUS db_allocate_id(unid_t *id, int id_type)
{
BOOL ret;
@@ -609,6 +647,7 @@ static void db_idmap_status(void)
static struct idmap_methods db_methods = {
db_idmap_init,
+ db_allocate_rid,
db_allocate_id,
db_get_sid_from_id,
db_get_id_from_sid,