private void inserisciUtenteInAmministrazione(OrgUtente utente, DataObject userDataObject) { string codiceAmm = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione); string gruppoAmm = TypeGruppo.GetGroupNameForAmministrazione(codiceAmm); try { //inserimento del nuovo utente nel gruppo associato alla amministrazione IQueryService qrySrvc = this.GetQueryServiceInstance(); DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoAmm, qrySrvc); // eventuale inserimento nel gruppo dei syadmin if (utente.Amministratore != null && utente.Amministratore != "0") { gruppoAmm = TypeGruppo.GetGroupNameForSysAdminAmministrazione(codiceAmm); DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoAmm, qrySrvc); } } catch (Exception e) { string msg = string.Format( DEBUG_HEADER + ": errore in inserimento utente {0} nel gruppo {1}: {2}", TypeUtente.getUserName(utente), gruppoAmm, e.ToString()); logger.Debug(msg); undoCreateUser(utente); throw new ApplicationException(msg, e); } }
public void InserisciUtenteInAmm(OrgUtente utente) { string codiceAmm = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione); string gruppoAmm = TypeGruppo.GetGroupNameForAmministrazione(codiceAmm); try { //inserimento del nuovo utente nel gruppo associato alla amministrazione IQueryService qrySrvc = this.GetQueryServiceInstance(); DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoAmm, qrySrvc); } catch (Exception e) { string msg = string.Format( DEBUG_HEADER + ": errore in inserimento utente {0} nel gruppo {1}: {2}", TypeUtente.getUserName(utente), gruppoAmm, e.ToString()); logger.Debug(msg); throw new ApplicationException(msg, e); } }
/// <summary> /// Modifica dei dati di un utente in amministrazione /// </summary> /// <param name="utente"></param> /// <returns></returns> public EsitoOperazione ModificaUtente(OrgUtente utente) { EsitoOperazione ret = new EsitoOperazione(); string logMsg = string.Empty; IObjectService objSrvc = null; IQueryService qrySvc = null; string repositoryName = DctmConfigurations.GetRepositoryName(); bool wasSysAdmin = false; bool isSysAdmin = false; string gruppoSysAdm; string codiceAmm; // test sui campi obbligatori if (string.IsNullOrEmpty(utente.Codice) || string.IsNullOrEmpty(utente.Email) || string.IsNullOrEmpty(utente.IDPeople) || string.IsNullOrEmpty(utente.UserId)) { logMsg = ERR_HEADER + "ModificaUtente: dati insufficienti"; ret.Codice = -1; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } try { objSrvc = this.GetObjectServiceInstance(); qrySvc = this.GetQueryServiceInstance(); ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente)); // non è possibile cambiare il nome di un utente List <string> filters = new List <string>(); filters.Add("user_name"); DataObject oldData = DfsHelper.getAllPropsAndFolders(objSrvc, userIdentity, filters, false); Property oldName = oldData.Properties.Get("user_name"); if (oldName == null) { ret.Codice = -1; logMsg = ERR_HEADER + "ModificaUtente: impossibile leggere il vecchio nome dell'utente"; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } if (!oldName.GetValueAsString().Equals(utente.UserId, StringComparison.OrdinalIgnoreCase)) { ret.Codice = -1; logMsg = ERR_HEADER + "ModificaUtente: non è possibile modificare il nome dell'utente"; ret.Descrizione = logMsg; logger.Debug(logMsg); return(ret); } // dobbiamo capire se prima dell'update era sysAdmin oppure no codiceAmm = DocsPaQueryHelper.getCodiceAmministrazione(utente.IDAmministrazione); gruppoSysAdm = TypeGruppo.GetGroupNameForSysAdminAmministrazione(codiceAmm); wasSysAdmin = DfsHelper.isUserMemberOf(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc); isSysAdmin = (utente.Amministratore != null && utente.Amministratore != "0"); // verifico se sia stata modificata la password o meno // if (!string.IsNullOrEmpty(utente.Password)) // { // eliminato controllo su presenza password, gli altri dati dell'utente devono essere modificati // anche senza un cambio password (speriamo almeno..) Necessario per replicare stato attivazione rispetto a docspa. // il campo password non viene passato se non è valorizzato DataObject userData = new DataObject(userIdentity, ObjectTypes.UTENTE); // Reperimento properties utente userData.Properties.Properties.AddRange(Dfs4DocsPa.getUserProperties(utente)); DataPackage pkg = new DataPackage(userData); pkg = objSrvc.Update(pkg, null); if (pkg.DataObjects.Count > 0) { // eventuale inserimento nel gruppo dei syadmin if (isSysAdmin && !wasSysAdmin) { DfsHelper.insertUserInGroup(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc); } else if (wasSysAdmin && !isSysAdmin) { DfsHelper.removeUserFromGroup(TypeUtente.getUserName(utente), gruppoSysAdm, qrySvc); } ret.Codice = 0; ret.Descrizione = string.Empty; logger.Debug(DEBUG_HEADER + "ModificaUtente completata con SUCCESSO"); } else { throw new ApplicationException(); } /** } * else * { * ret.Codice = 0; * ret.Descrizione = string.Empty; * * logger.Debug(DEBUG_HEADER + "ModificaUtente completata con SUCCESSO"); * } */ return(ret); } catch (Exception ex) { String st = ex.ToString(); logger.Error(DEBUG_HEADER + "ModificaUtente FALLITA, Exception=" + st); ret.Codice = -1; ret.Descrizione = ERR_HEADER + "ModificaUtente"; return(ret); } }