public IActionResult userResetPassword(userResetPasswordReq req) { try { //int domain_id = DAC.MeucciDAC.GetDimainId(req.DomainName); if (req.ResetUserCAIS == false) { //Regla Si se intenta resetear por tercera o más veces un UW el mismo día, var intentos = MeucciDAC.ValidarteIntentos(req.WindowsUser, req.dom_id, Common.resetear); if (intentos > 2) { throw new Fwk.Exceptions.FunctionalException("No es posible resetear más de dos veces el Usuario Windows el mismo día. Por favor comuníquese con el CAIS."); } } //Si el usuario pertenece al CAIS será obligatoria la carga del Nº de Ticket. if (req.ResetUserCAIS) { if (string.IsNullOrEmpty(req.ticket)) { throw new Fwk.Exceptions.FunctionalException("El Nº de Ticket es obligatorio .-"); } } req.newPassword = _LDAPService.GetRandomPassword(); var fwk_domain_name = _LDAPService.Get_correct_DomainName(req.DomainName); ActiveDirectoryService.User_Reset_Password(req.WindowsUser, req.newPassword, fwk_domain_name); DAC.MeucciDAC.ReseteoWeb_Log(req.Emp_Id, req.WindowsUser, req.dom_id, req.ResetUserId, req.ticket, Common.resetear, req.host); DAC.MeucciDAC.ReseteoWeb_EnviosMails(req.Emp_Id, req.WindowsUser, req.dom_id, req.ResetUserId, Common.resetear, req.host); //return apiHelper.fromObject<String>("El reseteo se realizó exitosamente. La contraseña provisoria es " + req.newPassword); return(Ok("El reseteo se realizó exitosamente. La contraseña provisoria es " + req.newPassword)); } catch (Exception ex) { //Acceso denegado. (Excepción de HRESULT: 0x80070005 (E_ACCESSDENIED)) var msg = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex, false); if (msg.ToLower().Contains("impersonali") || msg.ToLower().Contains("acceso")) { TechnicalException t = new TechnicalException("No es posible desbloquear " + req.WindowsUser + " en el dominio " + req.DomainName + " deberá comunicarse con el CAIS"); ex = t; } if (msg.Contains("E_ACCESSDENIED")) { TechnicalException t = new TechnicalException("No es posible desbloquear " + req.WindowsUser + " en el dominio " + req.DomainName + " deberá comunicarse con el CAIS"); ex = t; } msg = apiHelper.getMessageException(ex); return(BadRequest(new ApiErrorResponse(HttpStatusCode.InternalServerError, msg))); } }
public IActionResult User_Unlock(userUnlockReq req) { try { if (req.ResetUserCAIS == false) { //regla se intenta desbloquear por tercera vez un UW el mismo día var intentos = MeucciDAC.ValidarteIntentos(req.WindowsUser, req.dom_id, Common.resetear); if (intentos > 2) { throw new Fwk.Exceptions.FunctionalException("No es posible desbloquear más de dos veces el Usuario Windows el mismo día. Por favor comuníquese con el CAIS."); } } //Si el usuario pertenece al CAIS será obligatoria la carga del Nº de Ticket. if (req.ResetUserCAIS) { if (String.IsNullOrEmpty(req.ticket)) { throw new Fwk.Exceptions.FunctionalException("El Nº de Ticket es obligatorio .-"); } } var fwk_domain_name = _LDAPService.Get_correct_DomainName(req.DomainName); ActiveDirectoryService.User_Unlock(req.WindowsUser, fwk_domain_name); DAC.MeucciDAC.ReseteoWeb_Log(req.emp_id, req.WindowsUser, req.dom_id, req.ResetUserId, req.ticket, Common.desbloquear, req.host); DAC.MeucciDAC.ReseteoWeb_EnviosMails(req.emp_id, req.WindowsUser, req.dom_id, req.ResetUserId, Common.desbloquear, req.host); return(Ok("El desbloqueo se realizó correctamente")); } catch (Exception ex) { var msg = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex, false); if (msg.ToLower().Contains("impersonali") || msg.ToLower().Contains("acceso")) { TechnicalException t = new TechnicalException("No es posible desbloquear " + req.WindowsUser + " en el dominio " + req.DomainName + " deberá comunicarse con el CAIS"); ex = t; } if (msg.Contains("E_ACCESSDENIED")) { TechnicalException t = new TechnicalException("No es posible desbloquear " + req.WindowsUser + " en el dominio " + req.DomainName + " deberá comunicarse con el CAIS"); ex = t; } msg = apiHelper.getMessageException(ex); return(BadRequest(new ApiErrorResponse(HttpStatusCode.InternalServerError, msg))); } }
public HttpResponseMessage userChangePasswordSelf(userChangePasswordReq req) { try { var intentos = MeucciDAC.ValidarteIntentos(req.userName, req.dom_id, Common.changePwdSelft); if (intentos >= 2) { throw new Fwk.Exceptions.FunctionalException("No es posible resetear más de dos veces el Usuario Windows el mismo día. Por favor comuníquese con el CAIS."); } var fwk_domain_name = _LDAPService.Get_correct_DomainName(req.domainName); //ActiveDirectoryService.User_Reset_Password(req.userName, req.newPassword, fwk_domain_name); DAC.MeucciDAC.ReseteoWeb_Log(req.emp_Id, req.userName, req.dom_id, req.userId, "", Common.changePwdSelft, req.host); //DAC.MeucciDAC.ReseteoWeb_EnviosMails(req.emp_Id, req.WindowsUser, req.dom_id, req.ResetUserId, Common.resetear, req.host); return(apiHelper.fromObject <String>("La contraseña se cambio exitosamente. ")); } catch (Exception ex) { var msg = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex, false); if (msg.ToLower().Contains("impersonali") || msg.ToLower().Contains("acceso")) { TechnicalException t = new TechnicalException("No es posible resetear " + req.userName + " en el dominio " + req.domainName + " deberá comunicarse con CAIS "); ex = t; } if (msg.Contains("E_ACCESSDENIED")) { TechnicalException t = new TechnicalException("No es posible resetear " + req.userName + " en el dominio " + req.domainName + " deberá comunicarse con CAIS "); ex = t; } return(apiHelper.fromEx(ex)); } }