From ec62d5a96896ed38894282cd7547d012f604c597 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 20 Sep 2004 11:02:14 +0000 Subject: r2444: Based on jmcd's patch, implement special lists for the ldap user attributes to delete. Richard, IMHO this is the better solution to the problem you currently have. Please review. Thanks, Volker (This used to be commit 6957d6a8921fbd97747258249d99b505a79cfcb4) --- source3/passdb/pdb_ldap.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'source3/passdb') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 4f9140d3a8..35dbf4f0dc 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -148,6 +148,27 @@ static char** get_userattr_list( int schema_ver ) return NULL; } +/************************************************************************** + Return the list of attribute names to delete given a user schema version. +**************************************************************************/ + +static char** get_userattr_delete_list( int schema_ver ) +{ + switch ( schema_ver ) { + case SCHEMAVER_SAMBAACCOUNT: + return get_attr_list( attrib_map_to_delete_v22 ); + + case SCHEMAVER_SAMBASAMACCOUNT: + return get_attr_list( attrib_map_to_delete_v30 ); + default: + DEBUG(0,("get_userattr_list: unknown schema version specified!\n")); + break; + } + + return NULL; +} + + /******************************************************************* Generate the LDAP search filter for the objectclass based on the version of the schema we are using. @@ -299,11 +320,11 @@ static NTSTATUS ldapsam_delete_entry(struct ldapsam_privates *ldap_state, really exist. */ for (attrib = attrs; *attrib != NULL; attrib++) { - if ((StrCaseCmp(*attrib, name) == 0) && - !(StrCaseCmp(*attrib, - get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_MOD_TIMESTAMP)))) { - DEBUG(10, ("ldapsam_delete_entry: deleting attribute %s\n", name)); - smbldap_set_mod(&mods, LDAP_MOD_DELETE, name, NULL); + if (strequal(*attrib, name)) { + DEBUG(10, ("ldapsam_delete_entry: deleting " + "attribute %s\n", name)); + smbldap_set_mod(&mods, LDAP_MOD_DELETE, name, + NULL); } } @@ -1520,7 +1541,7 @@ static NTSTATUS ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_A DEBUG (3, ("ldapsam_delete_sam_account: Deleting user %s from LDAP.\n", sname)); - attr_list= get_userattr_list( ldap_state->schema_ver ); + attr_list= get_userattr_delete_list( ldap_state->schema_ver ); rc = ldapsam_search_suffix_by_name(ldap_state, sname, &result, attr_list); if (rc != LDAP_SUCCESS) { -- cgit