summaryrefslogtreecommitdiff
path: root/source3/groupdb
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2004-03-14 10:24:19 +0000
committerVolker Lendecke <vlendec@samba.org>2004-03-14 10:24:19 +0000
commit5b0f30e01c5a51f98025b035bfa5e00eb0268fef (patch)
tree46e4a3d4e1bed72363fb8332642af9639a7fffb6 /source3/groupdb
parentaf6225afa95cf1d8dd6bb1bfb438daaf6097e30a (diff)
downloadsamba-5b0f30e01c5a51f98025b035bfa5e00eb0268fef.tar.gz
samba-5b0f30e01c5a51f98025b035bfa5e00eb0268fef.tar.bz2
samba-5b0f30e01c5a51f98025b035bfa5e00eb0268fef.zip
Add and delete aliases via srv_samr_nt. For that I added a RID allocation call
to winbindd. idmap_allocate_rid wants information about whether this will be a user or a group, I did not export this to the winbind interface. The reason for idmap to get that info is to keep consistent with the algorithmic convention to alloc only even rids for users and odd rids for groups. I'm not fully convinced that this really gains us anything. Any real good arguments? Volker (This used to be commit 7f62cf933cad69799204bfdc773e08ff0dde0b20)
Diffstat (limited to 'source3/groupdb')
-rw-r--r--source3/groupdb/mapping.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 818a4acb84..cbf022f377 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -362,7 +362,7 @@ static BOOL get_group_map_from_ntname(const char *name, GROUP_MAP *map)
Remove a group mapping entry.
****************************************************************************/
-static BOOL group_map_remove(DOM_SID sid)
+static BOOL group_map_remove(const DOM_SID *sid)
{
TDB_DATA kbuf, dbuf;
pstring key;
@@ -375,7 +375,7 @@ static BOOL group_map_remove(DOM_SID sid)
/* the key is the SID, retrieving is direct */
- sid_to_string(string_sid, &sid);
+ sid_to_string(string_sid, sid);
slprintf(key, sizeof(key), "%s%s", GROUP_PREFIX, string_sid);
kbuf.dptr = key;
@@ -1266,7 +1266,7 @@ NTSTATUS pdb_default_update_group_mapping_entry(struct pdb_methods *methods,
NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods,
DOM_SID sid)
{
- return group_map_remove(sid) ?
+ return group_map_remove(&sid) ?
NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@@ -1289,13 +1289,45 @@ NTSTATUS pdb_default_find_alias(struct pdb_methods *methods,
NTSTATUS pdb_default_create_alias(struct pdb_methods *methods,
const char *name, uint32 *rid)
{
- return NT_STATUS_ACCESS_DENIED;
+ DOM_SID sid;
+ enum SID_NAME_USE type;
+ uint32 new_rid;
+ gid_t gid;
+
+ if (lookup_name(get_global_sam_name(), name, &sid, &type))
+ return NT_STATUS_ALIAS_EXISTS;
+
+ if (!winbind_allocate_rid(&new_rid))
+ return NT_STATUS_ACCESS_DENIED;
+
+ sid_copy(&sid, get_global_sam_sid());
+ sid_append_rid(&sid, new_rid);
+
+ /* Here we allocate the gid */
+ if (!winbind_sid_to_gid(&gid, &sid)) {
+ DEBUG(0, ("Could not get gid for new RID\n"));
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ if (!add_initial_entry(gid, sid_string_static(&sid), SID_NAME_ALIAS,
+ name, "")) {
+ DEBUG(0, ("Could not add group mapping entry for alias %s\n",
+ name));
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ *rid = new_rid;
+
+ return NT_STATUS_OK;
}
NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods,
const DOM_SID *sid)
{
- return NT_STATUS_ACCESS_DENIED;
+ if (!group_map_remove(sid))
+ return NT_STATUS_ACCESS_DENIED;
+
+ return NT_STATUS_OK;
}
NTSTATUS pdb_default_enum_aliases(struct pdb_methods *methods,