/// <summary> /// Verifica credenziali utente /// </summary> /// <param name="userName"></param> protected virtual bool VerifyCredentials(string userName, string authenticationToken, out DocsPaVO.utente.UserLogin.LoginResult loginResult) { bool retValue = false; loginResult = UserLogin.LoginResult.APPLICATION_ERROR; try { ObjectIdentity identity = Dfs4DocsPa.getUserHomeFolderIdentity(userName); IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(authenticationToken); logger.Debug("Inizio richiamo authenticationToken"); DataPackage dataPackage = objectService.Get(new ObjectIdentitySet(identity), null); logger.Debug("Fine chiamata authenticationToken"); retValue = (dataPackage != null); } /* * catch (Emc.Documentum.FS.Runtime.AuthenticationException exAuth) * { * //AuthenticationException - Exception in com.emc.documentum.fs.rt * //Exception which is raised when authentication errors occur * loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_DTCM_USER; * retValue = false; * * logger.Debug(string.Format("Credenziali utente DTCM non valide: '{0}'", userName)); * } */ catch (Emc.Documentum.FS.Runtime.ServiceInvocationException exServiceInvocation) { //AuthenticationException - Exception in com.emc.documentum.fs.rt //Exception which is raised when authentication errors occur loginResult = DocsPaVO.utente.UserLogin.LoginResult.DTCM_SERVICE_NO_CONTACT; retValue = false; logger.Debug(string.Format("Errore nel tentativo di contattare i servizi DOCUMENTUM: '{0}'", userName)); } /* * catch (Emc.Documentum.FS.Runtime.ServiceException exService) * { * //AuthenticationException - Exception in com.emc.documentum.fs.rt * //Exception which is raised when authentication errors occur * loginResult = DocsPaVO.utente.UserLogin.LoginResult.DTCM_SERVICE_NO_CONTACT; * retValue = false; * * logger.Debug(string.Format("Errore nel tentativo di contattare i servizi DTCM: '{0}'", userName)); * } */ catch (Exception ex) { //AuthenticationException - Exception in com.emc.documentum.fs.rt //Exception which is raised when authentication errors occur loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_USER; retValue = false; logger.DebugFormat("Credenziali utente non DCTM valide: '{0}' msg {1} stk {2}", userName, ex.Message, ex.StackTrace); } return(retValue); }
/// <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); } }
/////// <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); }