}
init_okay = init_ldap_from_sam(ldap_state, entry, &mods, user, pdb_element_is_set_or_changed);
- smbldap_talloc_autofree_ldapmod(tmp_ctx, mods);
if (!init_okay) {
DEBUG(1,("ldapsam_create_user: Unable to fill user structs\n"));
+ ldap_mods_free(mods, true);
return NT_STATUS_UNSUCCESSFUL;
}
if (!sid_compose(&group_sid, get_global_sam_sid(), DOMAIN_RID_USERS) ||
!sid_to_gid(&group_sid, &gid)) {
DEBUG (0, ("ldapsam_create_user: Unable to get the Domain Users gid: bailing out!\n"));
+ ldap_mods_free(mods, true);
return NT_STATUS_INVALID_PRIMARY_GROUP;
}
/* lets allocate a new userid for this user */
if (!winbind_allocate_uid(&uid)) {
DEBUG (0, ("ldapsam_create_user: Unable to allocate a new user id: bailing out!\n"));
+ ldap_mods_free(mods, true);
return NT_STATUS_UNSUCCESSFUL;
}
escape_name = escape_rdn_val_string_alloc(name);
if (!escape_name) {
DEBUG (0, ("ldapsam_create_user: Out of memory!\n"));
+ ldap_mods_free(mods, true);
return NT_STATUS_NO_MEMORY;
}
if (!homedir || !shell || !uidstr || !gidstr || !dn) {
DEBUG (0, ("ldapsam_create_user: Out of memory!\n"));
+ ldap_mods_free(mods, true);
return NT_STATUS_NO_MEMORY;
}
rc = smbldap_modify(ldap_state->smbldap_state, dn, mods);
}
+ ldap_mods_free(mods, true);
+
if (rc != LDAP_SUCCESS) {
DEBUG(0,("ldapsam_create_user: failed to create a new user [%s] (dn = %s)\n", name ,dn));
return NT_STATUS_UNSUCCESSFUL;