From aed54afc2cfc468d29b65b2b503d975070515528 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 29 Jan 2003 18:47:57 +0000 Subject: playing janitor for abartlet. :-( " Make the vampire code use just pdb calls - allowing better operation on systems that are not configured with an add user script, and have an _nua backend for storage. We really need to get the PDB backends out of the IDMAP game... Andrew Bartlett " (This used to be commit e959a8eb67e78bb90ae017687dca8f8b3b147b09) --- source3/utils/net_rpc_samsync.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 1bd39e3ebb..ac3b78fc7a 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -287,6 +287,7 @@ fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) GROUP_MAP map; struct group *grp; DOM_SID sid; + BOOL try_add = False; fstrcpy(account, unistr2_static(&delta->uni_acct_name)); d_printf("Creating account: %s\n", account); @@ -295,10 +296,6 @@ fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) return nt_ret; if (!pdb_getsampwnam(sam_account, account)) { - struct passwd *pw; - - pdb_free_sam(&sam_account); - /* Create appropriate user */ if (delta->acb_info & ACB_NORMAL) { pstrcpy(add_script, lp_adduser_script()); @@ -319,29 +316,25 @@ fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) DEBUG(1,("fetch_account: Running the command `%s' " "gave %d\n", add_script, add_ret)); } - pw = getpwnam_alloc(account); - if (pw) { - nt_ret = pdb_init_sam_pw(&sam_account, pw); - - if (!NT_STATUS_IS_OK(nt_ret)) { - passwd_free(&pw); - pdb_free_sam(&sam_account); - return nt_ret; - } - passwd_free(&pw); - } else { - DEBUG(3, ("Could not create account %s\n", account)); - pdb_free_sam(&sam_account); - return NT_STATUS_NO_SUCH_USER; + + if (!pdb_getsampwnam(sam_account, account)) { + try_add = True; + /* still not there, hope the backend likes NUAs */ } } sam_account_from_delta(sam_account, delta); - if (!pdb_add_sam_account(sam_account)) { - DEBUG(1, ("SAM Account for %s already exists, updating\n", - account)); - pdb_update_sam_account(sam_account); + if (try_add) { + if (!pdb_add_sam_account(sam_account)) { + DEBUG(1, ("SAM Account for %s failed to be added to the passdb!\n", + account)); + } + } else { + if (!pdb_update_sam_account(sam_account)) { + DEBUG(1, ("SAM Account for %s failed to be updated in the passdb!\n", + account)); + } } sid = *pdb_get_group_sid(sam_account); -- cgit