mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
s3:pdb_ldap: move some code in ldapsam_create_dom_group()
to make the flow more similar to ldapsam_create_user(). This prepares for calling winbind_sid_to_gid() instead of winbind_allocate_gid(): we need the group_sid for this... Michael
This commit is contained in:
parent
0dc3cd75a1
commit
c45eca5751
@ -5655,12 +5655,35 @@ static NTSTATUS ldapsam_create_dom_group(struct pdb_methods *my_methods,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (num_result == 0) {
|
if (num_result == 0) {
|
||||||
|
is_new_entry = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_STATUS_IS_OK((ret = ldapsam_new_rid_internal(my_methods, rid)))) {
|
||||||
|
DEBUG(1, ("ldapsam_create_group: Could not allocate a new RID\n"));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
sid_compose(&group_sid, get_global_sam_sid(), *rid);
|
||||||
|
|
||||||
|
groupsidstr = talloc_strdup(tmp_ctx, sid_string_talloc(tmp_ctx,
|
||||||
|
&group_sid));
|
||||||
|
grouptype = talloc_asprintf(tmp_ctx, "%d", SID_NAME_DOM_GRP);
|
||||||
|
|
||||||
|
if (!groupsidstr || !grouptype) {
|
||||||
|
DEBUG(0,("ldapsam_create_group: Out of memory!\n"));
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
smbldap_set_mod(&mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_GROUPMAP);
|
||||||
|
smbldap_set_mod(&mods, LDAP_MOD_ADD, "sambaSid", groupsidstr);
|
||||||
|
smbldap_set_mod(&mods, LDAP_MOD_ADD, "sambaGroupType", grouptype);
|
||||||
|
smbldap_set_mod(&mods, LDAP_MOD_ADD, "displayName", name);
|
||||||
|
|
||||||
|
if (is_new_entry) {
|
||||||
char *escape_name;
|
char *escape_name;
|
||||||
|
|
||||||
DEBUG(3,("ldapsam_create_user: Creating new posix group\n"));
|
DEBUG(3,("ldapsam_create_user: Creating new posix group\n"));
|
||||||
|
|
||||||
is_new_entry = True;
|
|
||||||
|
|
||||||
/* lets allocate a new groupid for this group */
|
/* lets allocate a new groupid for this group */
|
||||||
if (!winbind_allocate_gid(&gid)) {
|
if (!winbind_allocate_gid(&gid)) {
|
||||||
DEBUG (0, ("ldapsam_create_group: Unable to allocate a new group id: bailing out!\n"));
|
DEBUG (0, ("ldapsam_create_group: Unable to allocate a new group id: bailing out!\n"));
|
||||||
@ -5689,26 +5712,6 @@ static NTSTATUS ldapsam_create_dom_group(struct pdb_methods *my_methods,
|
|||||||
smbldap_set_mod(&mods, LDAP_MOD_ADD, "gidNumber", gidstr);
|
smbldap_set_mod(&mods, LDAP_MOD_ADD, "gidNumber", gidstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK((ret = ldapsam_new_rid_internal(my_methods, rid)))) {
|
|
||||||
DEBUG(1, ("ldapsam_create_group: Could not allocate a new RID\n"));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
sid_compose(&group_sid, get_global_sam_sid(), *rid);
|
|
||||||
|
|
||||||
groupsidstr = talloc_strdup(tmp_ctx, sid_string_talloc(tmp_ctx,
|
|
||||||
&group_sid));
|
|
||||||
grouptype = talloc_asprintf(tmp_ctx, "%d", SID_NAME_DOM_GRP);
|
|
||||||
|
|
||||||
if (!groupsidstr || !grouptype) {
|
|
||||||
DEBUG(0,("ldapsam_create_group: Out of memory!\n"));
|
|
||||||
return NT_STATUS_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
smbldap_set_mod(&mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_GROUPMAP);
|
|
||||||
smbldap_set_mod(&mods, LDAP_MOD_ADD, "sambaSid", groupsidstr);
|
|
||||||
smbldap_set_mod(&mods, LDAP_MOD_ADD, "sambaGroupType", grouptype);
|
|
||||||
smbldap_set_mod(&mods, LDAP_MOD_ADD, "displayName", name);
|
|
||||||
talloc_autofree_ldapmod(tmp_ctx, mods);
|
talloc_autofree_ldapmod(tmp_ctx, mods);
|
||||||
|
|
||||||
if (is_new_entry) {
|
if (is_new_entry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user