Пример #1
0
        /// <summary>
        /// Impostazione della visibilità su un fascicolo
        /// (e dell'ownership, nel caso l'utente / ruolo rimosso fosse il proprietario)
        /// </summary>
        /// <param name="infoDiritto"></param>
        /// <returns></returns>
        public bool AddPermission(DocsPaVO.fascicolazione.DirittoOggetto infoDiritto)
        {
            bool added = false;

            // se si revocano i diritti all'utente proprietario,
            // si revocano anche al ruolo proprietario e viceversa.
            // Il proprietario del documento diventa l'utente e il ruolo del revocante

            try
            {
                // Reperimento utente proprietario
                string ownerUser = TypeUtente.NormalizeUserName(DocsPaQueryHelper.getCodiceRubricaProprietario(infoDiritto.idObj, true));

                // Modifica ownership del fascicolo
                if (this.SetOwnershipFascicolo(infoDiritto.idObj, ownerUser))
                {
                    CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinition(infoDiritto.idObj, ObjectTypes.FASCICOLO, this.InfoUtente);

                    CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser());

                    aclService.ClearAndGrant(aclDefinition, infoDiritto.idObj);

                    added = true;
                }
            }
            catch (Exception ex)
            {
                added = false;

                logger.Debug(string.Format("Errore in Documentum.RemovePermission:\n{0}", ex.ToString()));
            }

            return(added);
        }
Пример #2
0
        /// <summary>
        /// Revoca della visibilità su un documento (e dell'ownership, nel caso l'utente / ruolo rimosso è proprietario)
        /// </summary>
        /// <param name="documentInfo"></param>
        /// <returns></returns>
        public bool RemovePermission(DocsPaVO.fascicolazione.DirittoOggetto infoDiritto)
        {
            bool removed = false;

            try
            {
                // Reperimento utente proprietario
                string ownerUser = TypeUtente.NormalizeUserName(DocsPaQueryHelper.getCodiceRubricaProprietario(infoDiritto.idObj, true));

                if (this.SetOwnershipFascicolo(infoDiritto.idObj, ownerUser))
                {
                    CustomServices.AclDefinition aclDefinition = Dfs4DocsPa.getAclDefinition(infoDiritto.idObj, ObjectTypes.FASCICOLO, this.InfoUtente);

                    CustomServices.IAclService aclService = DctmServiceFactory.GetCustomServiceInstance <CustomServices.IAclService>(UserManager.ImpersonateSuperUser());

                    aclService.ClearAndGrant(aclDefinition, infoDiritto.idObj);
                }

                removed = true;
            }
            catch (Exception ex)
            {
                removed = false;

                logger.Debug(string.Format("Errore in Documentum.RemovePermission:\n{0}", ex.ToString()));
            }

            return(removed);
        }
Пример #3
0
        /// <summary>
        /// Inserimento di un utente in un ruolo
        /// </summary>
        /// <param name="idPeople"></param>
        /// <param name="idGruppo"></param>
        /// <returns></returns>
        public EsitoOperazione InserisciUtenteInRuolo(string idPeople, string idGruppo)
        {
            EsitoOperazione ret = new EsitoOperazione();

            IQueryService qrySrvc = null;

            try
            {
                qrySrvc = this.GetQueryServiceInstance();

                string codiceRuolo  = DocsPaServices.DocsPaQueryHelper.getCodiceRuoloFromIdGroups(idGruppo);
                string codiceUtente = DocsPaServices.DocsPaQueryHelper.getCodiceUtente(idPeople);

                string query = string.Format("ALTER GROUP '{0}' ADD '{1}'",
                                             TypeGruppo.NormalizeGroupName(codiceRuolo),
                                             TypeUtente.NormalizeUserName(codiceUtente));

                QueryResult queryResult = DfsHelper.executePassThrough(qrySrvc, query);

                logger.Debug(DEBUG_HEADER + "InserisciUtenteInRuolo completata con SUCCESSO");
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Debug(DEBUG_HEADER + "InserisciUtenteInRuolo FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "InserisciUtenteInRuolo";
                return(ret);
            }
        }
Пример #4
0
        /// <summary>
        /// Eliminazione di un utente da gruppo di amministrazione
        /// </summary>
        /// <param name="idPeople"></param>
        /// <param name="idGruppo"></param>
        /// <returns></returns>
        public EsitoOperazione EliminaUtenteDaRuoloAmm(string userId, string idAmministrazione)
        {
            EsitoOperazione ret     = new EsitoOperazione();
            IQueryService   qrySrvc = null;

            try
            {
                qrySrvc = this.GetQueryServiceInstance();

                string codiceAmministrazione = string.Format("sys_{0}", DocsPaServices.DocsPaQueryHelper.getCodiceAmministrazione(idAmministrazione).ToLower());

                string query = string.Format("ALTER GROUP '{0}' DROP '{1}'",
                                             TypeGruppo.NormalizeGroupName(codiceAmministrazione).ToLower(),
                                             TypeUtente.NormalizeUserName(userId).ToLower());

                QueryResult queryResult = DfsHelper.executePassThrough(qrySrvc, query);

                logger.Debug(DEBUG_HEADER + "EliminaUtenteDaRuoloAmm completata con SUCCESSO");
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Debug(DEBUG_HEADER + "EliminaUtenteDaRuoloAmm FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "EliminaUtenteDaRuoloAmm";
                return(ret);
            }
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        /// <summary>
        /// Elimina un utente in amministrazione
        /// </summary>
        /// <param name="utente"></param>
        /// <returns></returns>
        public EsitoOperazione EliminaUtenteAmm(OrgUtente utente)
        {
            EsitoOperazione ret = new EsitoOperazione();
            string          logMsg;
            IObjectService  objSrvc        = null;
            String          repositoryName = DctmConfigurations.GetRepositoryName();

            // test sui campi obbligatori
            if (string.IsNullOrEmpty(utente.UserId))
            {
                logMsg          = ERR_HEADER + "EliminaUtente: dati insufficienti";
                ret.Codice      = -1;
                ret.Descrizione = logMsg;
                logger.Debug(logMsg);
                return(ret);
            }

            try
            {
                // verifica se esistono più di un'occorrenza per utente
                if (CountGroupsByUser(utente.UserId) > 1)
                {
                    // rimuove l'utente dal gruppo di root
                    EliminaUtenteDaRuoloAmm(utente.UserId, utente.IDAmministrazione);
                }
                else
                {
                    ObjectIdentitySet identitySet = new ObjectIdentitySet();
                    objSrvc = this.GetObjectServiceInstance();
                    ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente));
                    // Cancellazione dell'home cabinet per l'utente
                    identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(utente.UserId));
                    identitySet.AddIdentity(userIdentity);
                    OperationOptions opts = new OperationOptions();
                    opts.DeleteProfile = new DeleteProfile();
                    opts.DeleteProfile.IsPopulateWithReferences = true;
                    objSrvc.Delete(identitySet, opts);
                    logger.Debug(DEBUG_HEADER + "EliminaUtente completata con SUCCESSO");
                }
                return(ret);
            }
            catch (Exception ex)
            {
                String st = ex.ToString();
                logger.Debug(DEBUG_HEADER + "EliminaUtente FALLITA, Exception=" + st);
                ret.Codice      = -1;
                ret.Descrizione = ERR_HEADER + "EliminaUtente";
                return(ret);
            }
        }
Пример #7
0
        /// <summary>
        /// Modifica password utente
        /// </summary>
        /// <param name="oldPassword"/></param>
        /// <param name="user"></param>
        ///// <returns></returns>
        public ValidationResultInfo ChangeUserPwd(DocsPaVO.utente.UserLogin user, string oldPassword)
        {
            ValidationResultInfo retValue = new ValidationResultInfo();

            try
            {
                // La password deve essere modificata con le credenziali di superuser
                IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());

                ObjectIdentity identity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.NormalizeUserName(user.UserName));

                DataObject userDataObject = new DataObject(identity, ObjectTypes.UTENTE);
                userDataObject.Properties.Set <string>("user_password", user.Password);

                DataPackage dataPackage = new DataPackage(userDataObject);
                dataPackage = objectService.Update(dataPackage, null);

                retValue.Value = (dataPackage.DataObjects.Count > 0);

                if (!retValue.Value)
                {
                    throw new ApplicationException("Password non aggiornata");
                }
                else
                {
                    RepositoryIdentity newIdentity = DctmRepositoryIdentityHelper.GetIdentity(DctmConfigurations.GetRepositoryName(), user.UserName, user.Password, string.Empty);
                    user.DST = DctmRepositoryIdentityHelper.CreateAuthenticationToken(newIdentity);

                    logger.Debug(string.Format("Documentum.ChangePassword: password modificata per l'utente {0}", user.UserName));
                }
            }
            catch (Exception ex)
            {
                logger.Debug(string.Format("Errore in Documentum.ChangePassword:\n{0}", ex.ToString()));

                retValue.BrokenRules.Add(new BrokenRule("ChangePassword_ERROR", "Errore nella modifica della password per il documentale DOCUMENTUM", DocsPaVO.Validations.BrokenRule.BrokenRuleLevelEnum.Error));
            }

            retValue.Value = (retValue.BrokenRules.Count == 0);

            return(retValue);
        }
Пример #8
0
        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);
            }
        }
Пример #9
0
 private void undoCreateHomeFolder(OrgUtente utente)
 {
     try
     {
         IObjectService objSrvc      = this.GetObjectServiceInstance();
         string         homePath     = "/" + TypeUtente.getHomeFolderName(utente.UserId);
         ObjectIdentity homeIdentity =
             new ObjectIdentity(new ObjectPath(homePath),
                                DctmConfigurations.GetRepositoryName());
         ObjectIdentitySet idSet = new ObjectIdentitySet(homeIdentity);
         objSrvc.Delete(idSet, null);
     }
     catch (Exception ex)
     {
         //se siamo arrivati qui, significa che siamo già in una condizione di errore
         //non è così grave: rimane un folder, che non pregiudica un eventuale nuovo tentativo dei definire l'utente
         //in ogni caso è inutile rilanciare l'eccezione: già il chiamante è in gestione di una ecc.
         logger.Debug(DEBUG_HEADER + "Impossibile annullare l'inserimento dell'home folder: " + ex.ToString());
     }
 }
Пример #10
0
        private bool undoCreateUser(OrgUtente utente)
        {
            try
            {
                ObjectIdentity userIdentity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.getUserName(utente));

                ObjectIdentitySet idSet = new ObjectIdentitySet(userIdentity);

                IObjectService objSrvc = this.GetObjectServiceInstance();
                objSrvc.Delete(idSet, null);

                return(true);
            }
            catch (Exception ex)
            {
                //se siamo arrivati qui, significa che siamo già in una condizione di errore
                //se si verifica un'eccezione qui, siamo nei guai: non riusciamo a fare un clean
                //in ogni caso è inutile rilanciare l'eccezione: già il chiamante è in gestione di una ecc.
                logger.Debug(DEBUG_HEADER + "GRAVE: impossibile annullare l'inserimento utente");
                return(false);
            }
        }
Пример #11
0
        /// <summary>
        /// Login al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            bool retValue = false;

            utente      = null;
            loginResult = UserLogin.LoginResult.UNKNOWN_USER;

            try
            {
                string userName     = TypeUtente.NormalizeUserName(userLogin.UserName);
                string userPassword = string.Empty;
                // Modifica 21-12-2012, recupero ticket documentum se login tramite token.
                //if (DocsPaServices.DocsPaQueryHelper.isUtenteDominioOrLdap(userLogin))
                if (userLogin.SSOLogin)
                {
                    // L'utente è agganciato in amministrazione ad un dominio,
                    // pertanto viene richiamato il servizio documentum per la generazione del ticket di autenticazione
                    userPassword = DctmTokenFactoryHelper.Generate(userName);
                }
                else
                {
                    userPassword = userLogin.Password;
                }

                RepositoryIdentity identity = DctmServices.DctmRepositoryIdentityHelper.GetIdentity(
                    DctmConfigurations.GetRepositoryName(),
                    userName,
                    userPassword,
                    userLogin.Dominio);

                string token = DctmServices.DctmRepositoryIdentityHelper.CreateAuthenticationToken(identity);

                // Verifica validità credenziali
                if (this.VerifyCredentials(userName, token, out loginResult))
                {
                    utente      = new Utente();
                    utente.dst  = token;
                    loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                }

                //per LDAP oppure per SHIBBOLETH
                if (userLogin.SSOLogin)
                {
                    utente.dst = UserManager.ImpersonateSuperUser();
                }
                //FINE per LDAP oppure per SHIBBOLETH


                retValue = (loginResult == DocsPaVO.utente.UserLogin.LoginResult.OK);
            }
            catch (Exception ex)
            {
                retValue    = false;
                utente      = null;
                loginResult = UserLogin.LoginResult.UNKNOWN_USER;

                logger.Debug(string.Format("Errore in Documentum.Login:\n{0}", ex.ToString()));
            }

            return(retValue);
        }
Пример #12
0
        /////// <summary>
        /////// Reperimento di tutti gli utenti dell'amministrazione
        /////// </summary>
        /////// <param name="infoUtente"></param>
        /////// <param name="amministrazione"></param>
        /////// <returns></returns>
        ////private static string[] GetUtenti(InfoAmministrazione amm)
        ////{
        ////    List<string> list = new List<string>();

        ////    using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
        ////    {
        ////        string commandText = string.Format("SELECT user_id FROM PEOPLE WHERE id_amm = {0}", amm.IDAmm);

        ////        using (System.Data.IDataReader reader = dbProvider.ExecuteReader(commandText))
        ////        {
        ////            while (reader.Read())
        ////            {
        ////                list.Add(DocsPaUtils.Data.DataReaderHelper.GetValue<string>(reader, "user_id", false));
        ////            }
        ////        }
        ////    }

        ////    return list.ToArray();
        ////}

        /// <summary>
        /// Cancellazione di un'amministrazione nel documentale.
        /// NB: L'operazione di rimozione deve essere effettuata con le credenziali
        /// dell'utente superuser
        /// </summary>
        /// <param name="info"></param>
        /// <param name="ruoliAmministrazione">
        /// Ruoli docspa da rimuovere in documentum
        /// </param>
        /// <returns></returns>
        public EsitoOperazione Delete(InfoAmministrazione info, string[] ruoliAmministrazione)
        {
            logger.Debug(string.Format("Documentum.DeleteAmministrazione: inizio rimozione amministrazione. Codice: '{0}'", info.Codice));

            EsitoOperazione retValue = new EsitoOperazione();

            try
            {
                ObjectIdentitySet identitySet = new ObjectIdentitySet();

                // Reperimento degli oggetti Identity relativi a tutti i gruppi e gli utenti dell'amministrazione
                IQueryService queryService = DctmServiceFactory.GetServiceInstance <IQueryService>(this.InfoUtente.dst);
                string[]      users        = Dfs4DocsPa.getUsersSystemGroup(info.Codice, queryService);

                // Cancellazione di tutti gli utenti legati al cabinet / amministrazione
                foreach (string userId in users)
                {
                    string normalizedUserId = TypeUtente.NormalizeUserName(userId);

                    // Reperimento oggetto identity per ogni utente
                    identitySet.AddIdentity(Dfs4DocsPa.getUserIdentityByName(normalizedUserId));

                    // Cancellazione dell'home cabinet per ogni 'utente
                    identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(normalizedUserId));

                    logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione utente '{0}'", normalizedUserId));
                }

                //foreach (string userId in GetUtenti(info))
                //{
                //    string normalizedUserId = TypeUtente.NormalizeUserName(userId);

                //    ObjectIdentity id = Dfs4DocsPa.getUserIdentityByName(normalizedUserId, queryService);

                //    if (id != null)
                //    {
                //        identitySet.AddIdentity(id);

                //        // Cancellazione dell'home cabinet per ogni 'utente
                //        identitySet.AddIdentity(Dfs4DocsPa.getUserHomeFolderIdentity(normalizedUserId));
                //    }
                //}

                // Cancellazione del ruolo di sistema dell'amministrazione
                ObjectIdentity identity = Dfs4DocsPa.getSystemGroupIdentity(info.Codice, queryService);

                if (identity != null)
                {
                    identitySet.AddIdentity(identity);
                }

                // Cancellazione del ruolo di sistema degli amministratori dell'amministrazione
                identity = Dfs4DocsPa.getAmmSystemGroupIdentity(info.Codice, queryService);

                if (identity != null)
                {
                    identitySet.AddIdentity(identity);
                }

                // Cancellazione di tutti gli gruppi legati al cabinet / amministrazione
                foreach (string docspaGroupName in ruoliAmministrazione)
                {
                    string normalizedGroupName = TypeGruppo.NormalizeGroupName(docspaGroupName);

                    ObjectIdentity groupIdentity = Dfs4DocsPa.getGroupIdentityByName(normalizedGroupName, queryService);

                    if (groupIdentity != null)
                    {
                        identitySet.AddIdentity(groupIdentity);

                        logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione ruolo '{0}'", normalizedGroupName));
                    }
                }

                // Reperimento oggetto Identity relativamente al cabinet da rimuovere
                identitySet.AddIdentity(Dfs4DocsPa.getCabinetIdentity(info.Codice));

                OperationOptions opts = new OperationOptions();
                opts.DeleteProfile = this.CreateDeleteProfile();

                IObjectService objectService = this.GetObjectServiceInstance();
                objectService.Delete(identitySet, opts);

                logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione amministrazione. Codice: '{0}'", info.Codice));

                // Cancellazione di tutte le ACL create per gli oggetti dell'amministrazione
                this.DeleteAcl(info);
                logger.Debug(string.Format("Documentum.DeleteAmministrazione: rimozione ACL amministrazione. Codice: '{0}'", info.Codice));
            }
            catch (Exception ex)
            {
                logger.Debug(string.Format("Errore in Documentum.DeleteAmministrazione:\n{0}", ex.ToString()));

                retValue.Codice      = -1;
                retValue.Descrizione = string.Format("Errore nella rimozione del cabinet {0} in Documentum", info.Codice);
            }

            return(retValue);
        }
Пример #13
0
        /// <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);
            }
        }
Пример #14
0
        /// <summary>
        /// Inserimento di un nuovo utente in amministrazione
        /// </summary>
        /// <param name="utente"></param>
        /// <returns></returns>
        public EsitoOperazione InserisciUtente(OrgUtente utente)
        {
            EsitoOperazione retValue = new EsitoOperazione();

            string logMsg      = string.Empty;
            bool   userCreated = false;
            bool   pathCreated = false;

            // test sui campi obbligatori
            if (string.IsNullOrEmpty(utente.Codice) ||
                string.IsNullOrEmpty(utente.Email) ||
                string.IsNullOrEmpty(utente.IDPeople) ||
                string.IsNullOrEmpty(utente.UserId))
            {
                retValue.Codice      = -1;
                retValue.Descrizione = ERR_HEADER + "InserisciUtente: dati insufficienti";
                logger.Debug(retValue.Descrizione);
            }
            else
            {
                try
                {
                    IObjectService objSrvc = this.GetObjectServiceInstance();
                    string         repo    = DctmConfigurations.GetRepositoryName();

                    string         homePath            = string.Concat("/", TypeUtente.getHomeFolderName(utente.UserId));
                    ObjectIdentity identityHomeCabinet = objSrvc.CreatePath(new ObjectPath(homePath), repo);
                    pathCreated = true;

                    ObjectIdentity userIdentity = new ObjectIdentity(repo);
                    DataObject     userData     = new DataObject(userIdentity, ObjectTypes.UTENTE);

                    // Reperimento properties utente
                    userData.Properties.Properties.AddRange(Dfs4DocsPa.getUserProperties(utente));
                    userData.Properties.Set <string>("default_folder", homePath);

                    DataPackage dataPackage = new DataPackage(userData);

                    dataPackage = objSrvc.Create(dataPackage, null);

                    if (dataPackage.DataObjects.Count > 0)
                    {
                        userCreated = true;

                        // Impotazione proprietà "is_private = 1", per fare in modo
                        // che il cabinet sia visibile solamente all'utente che l'ha creato
                        // e 'owner_name' con il nome dell'utente
                        DataObject homeCabinetData = new DataObject(identityHomeCabinet, "dm_cabinet");
                        //homeCabinetData.Properties.Set<int>("is_private", 1);  //Vecchio 6.0
                        homeCabinetData.Properties.Set <string>("is_private", "1");
                        homeCabinetData.Properties.Set <string>("owner_name", TypeUtente.getUserName(utente));

                        dataPackage = new DataPackage(homeCabinetData);
                        dataPackage = objSrvc.Update(dataPackage, null);

                        if (dataPackage.DataObjects.Count > 0)
                        {
                            this.inserisciUtenteInAmministrazione(utente, userData);

                            retValue.Codice      = 0;
                            retValue.Descrizione = string.Empty;
                            logger.Debug(DEBUG_HEADER + "InserisciUtente completata con SUCCESSO");
                        }
                        else
                        {
                            throw new ApplicationException();
                        }
                    }
                    else
                    {
                        undoCreateHomeFolder(utente);
                        pathCreated = false;
                        throw new ApplicationException();
                    }
                }
                catch (Exception ex)
                {
                    string errorMessage = string.Format("Errore in {0}: {1}", DEBUG_HEADER, ex.ToString());

                    logger.Debug(errorMessage);
                    retValue.Codice      = -1;
                    retValue.Descrizione = ERR_HEADER + "InserisciUtente";

                    if (pathCreated)
                    {
                        this.undoCreateHomeFolder(utente);
                    }

                    if (userCreated)
                    {
                        this.undoCreateUser(utente);
                    }
                }
            }

            return(retValue);
        }