} // CanExecuteOk #endregion #region METHODS /// <summary> /// /// </summary> /// <remarks> /// Sin comentarios adicionales /// </remarks> public void ExecuteOk() { ApplicationContext.UserContext = new UserContextDto(); this.DialogResult = true; try { AuthenticationServiceClient loginSvc = new AuthenticationServiceClient(); int applicationId = 2; if (ConfigurationManager.AppSettings.AllKeys.Contains("applicationId")) { applicationId = int.Parse(ConfigurationManager.AppSettings["applicationId"]); } UserContextDto userContext = loginSvc.Login(new UserCredentialsDto(this.Login, this.Password, string.Empty, applicationId, string.Empty)); if (userContext != null) { ApplicationContext.UserContext = userContext; this.DialogResult = true; } else { this.DialogResult = false; } } catch (System.Exception ex) { this.DialogResult = false; } } // ExecuteOk
private async void buttonEditUser_Click(object sender, EventArgs e) { ClearErrorProvidres(); BuildUser(); try { AuthenticationServiceClient client = new AuthenticationServiceClient(); Form frm = new ProgressForm(); frm.Show(); OperationResult serviceResult = await client.UpdateUserAsync(user); frm.Close(); if (CheckServiceResult(serviceResult)) { DialogResult = DialogResult.OK; Close(); } } catch (FaultException <Models.Faults.InvalidRoleFault> exc) { MessageBox.Show(exc.Message); } catch (FaultException exc) { MessageBox.Show(exc.Message); } }
private void buttonSignIn_Click(object sender, EventArgs e) { try { AuthenticationServiceClient client = new AuthenticationServiceClient(); OperationResult <User> result = client.AuthorizationUser(textBoxLogin.Text, textBoxPassword.Text); if (result.Success) { Hide(); if (result.Result.Roles.First <Role>().RoleName.Equals("Admin")) { AdminForm adminForm = new AdminForm(result.Result); adminForm.FormClosed += FormClosed; adminForm.Show(); } else { OtherUserForm otherUserForm = new OtherUserForm(result.Result); otherUserForm.FormClosed += FormClosed; otherUserForm.Show(); } } else { MessageBox.Show("Invalid login or password!"); } } catch (FaultException exc) { MessageBox.Show(exc.Message); } }
public void Logout() { AuthenticationServiceClient client = new AuthenticationServiceClient(); OperationContextScope scope = new OperationContextScope(client.InnerChannel); var prop = new HttpRequestMessageProperty(); prop.Headers.Add(HttpRequestHeader.Cookie, ModelLocator.getInstance().SessionModel.SessionCookie); OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = prop; try { client.Logout(); mResponder.LogoutResult(); } catch (FaultException <ONyRFaultException> ex) { mResponder.LogoutFault((ErrorCode)ex.Detail.ErrorCode); } catch (Exception) { mResponder.LogoutFault(ErrorCode.NonONyRError); } finally { if (client != null) { client.Close(); } } }
public void Logout() { using (AuthenticationServiceClient proxy = new AuthenticationServiceClient()) { proxy.Logout(); } }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); AuthenticationClient = new AuthenticationServiceClient(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } }
/// <summary> /// The login action. /// </summary> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <returns>Redirect to index view result.</returns> public ActionResult Login(string username, string password) { // Build the request var request = new AuthenticateRequest { Username = username, Password = password }; // Call the service and get a response AuthenticateResponse response; using (var client = new AuthenticationServiceClient()) { response = client.AuthenticateUser(request); } // If not authenticated, make a note for model state if (!response.IsAuthenticated) { TempData.Add("Authentication", "The username/password did not match any user."); } // Redirect to the index view return RedirectToAction("Index"); }
/// <summary> Constructs a Clients object as needed for authentication. </summary> public Clients() { BaseEndpoint = new Uri(ConfigurationManager.AppSettings["IntranetEndpoint"]); Auth = new AuthenticationServiceClient( new BasicHttpBinding(), new EndpointAddress(new Uri(BaseEndpoint, "Authentication.svc"))); }
private async void SearchUserButton_Click(object sender, EventArgs e) { try { AuthenticationServiceClient client = new AuthenticationServiceClient(); string roleName = comboBoxRole.Text; if (roleName.ToLower().Equals("all roles")) { roleName = ""; } Form frm = new ProgressForm(); frm.Show(); User[] users = await client.SearchUserAsync(textBoxLogin.Text, textBoxFullName.Text, roleName); frm.Close(); dataGridViewSearch.DataSource = new BindingList <ClientUser>(users.Select(user => new ClientUser(user)).ToList()); if (users.Length == 0) { MessageBox.Show("Users not found!"); } } catch (FaultException exc) { MessageBox.Show(exc.Message); } }
public bool ValidateUser(string username, string password, string customCredential) { using (AuthenticationServiceClient proxy = new AuthenticationServiceClient()) { return proxy.ValidateUser(username, password, customCredential); } }
// Executes when the user navigates to this page. protected override void OnNavigatedTo(NavigationEventArgs e) { AuthenticationServiceClient client; client = new AuthenticationServiceClient(); client.LogOutCompleted += LogOutCompleted; client.LogOutAsync(); }
protected void Page_Load(object sender, EventArgs e) { updateEntity = new Person(); updateUser = new UserAccount(); proxyAuth = new AuthenticationServiceClient("WSHttpBinding_IAuthenticationService"); proxyPolicy = new PolicyPasswordAdminServiceClient("WSHttpBinding_IPolicyPasswordAdminService"); string cuenta = Request.Params["Account"].ToString(); string pass = Request.Params["Password"].ToString(); long userID = proxyAuth.GetID(cuenta, pass); updateEntity = GetPerson(userID); updateUser = GetUser(userID); if (!IsPostBack) { txt_Nombre.Text = updateEntity.Name; txt_APaterno.Text = updateEntity.FirstName; txt_AMaterno.Text = updateEntity.LastName; txt_CI.Text = updateEntity.IdentityCard.ToString(); txt_Profesion.Text = updateEntity.Profession; txt_Email.Text = updateEntity.Email; txt_Celular.Text = updateEntity.MobilePhone.ToString(); txt_Fono.Text = updateEntity.HomePhone.ToString(); txt_Domicilio.Text = updateEntity.HomeAddress; txt_CPostal.Text = updateEntity.PostalCode.ToString(); txt_Pass.Text = updateUser.Password; } }
private void LoadRoles() { AuthenticationServiceClient client = new AuthenticationServiceClient(); Task <Role[]> rolesTask = client.GetAllRolesAsync(); rolesTask.ContinueWith(task => { Invoke(new Action(() => { try { comboBoxRole.Items.Clear(); foreach (string role in task.Result.Select(r => r.RoleName)) { comboBoxRole.Items.Add(role); } Enabled = true; } catch (FaultException <Models.Faults.InvalidRoleFault> exc) { MessageBox.Show(exc.Message); } catch (FaultException exc) { MessageBox.Show(exc.Message); } })); }); }
public static ValidationResult AuthenticateUser(string userName, string password) { var client = new AuthenticationServiceClient("WSHttpBinding_IAuthenticationService"); var userDetails = new UserDetails() { UserName = userName, Password = password }; var authenticationResult = client.AuthenticateUser(userDetails); return authenticationResult; }
public void SaveCurrentAssignmentAsync(byte[] assignmentData) { AuthenticationServiceClient authClient = new AuthenticationServiceClient(); authClient.ValidateUserCompleted += this.ValidateForSaveCompleted; authClient.ValidateUserAsync(m_userName, m_password, new object[] { authClient, assignmentData }); }
private async void buttonChangePassword_Click(object sender, EventArgs e) { ClearErrorProvidres(); if (!ValidateUserData()) { return; } try { AuthenticationServiceClient client = new AuthenticationServiceClient(); Form frm = new ProgressForm(); frm.Show(); OperationResult serviceResult = await client.ChangePasswordAsync(user, textBoxNewPassword.Text); frm.Close(); if (serviceResult.Success) { Close(); } if (serviceResult.Errors.Contains(OperationErrors.PassErr)) { errorProviderNewPassword.SetError(textBoxNewPassword, "Password is not valid!"); } } catch (FaultException exc) { MessageBox.Show(exc.Message); } }
private async void CreateUserButtonClick(object sender, EventArgs e) { ClearErrorProvidres(); if (!ValidateUserData()) { return; } User user = BuildNewUser(); try { AuthenticationServiceClient client = new AuthenticationServiceClient(); Form frm = new ProgressForm(); frm.Show(); OperationResult serviceResult = await client.CreateUserAsync(user, textBoxPassword.Text); frm.Close(); if (CheckServiceResult(serviceResult)) { Close(); } } catch (FaultException <InvalidRoleFault> exc) { MessageBox.Show(exc.Message); } catch (FaultException exc) { MessageBox.Show(exc.Message); } }
public Entities.User TryAuthentication(string login, string password) { using (var client = new AuthenticationServiceClient()) { OperationResultOfUser result = client.AuthorizationUser(login, password); return(ServiceMapper.Mapper.Map <Entities.User>(result.Result)); } }
public ActionResult DeleteUser(int id) { using (var admin = new AuthenticationServiceClient()) { admin.DeleteUser(id); } return(RedirectToAction("Index", "Admin")); }
protected void Page_Load(object sender, EventArgs e) { value = 0; proxy = new AuthenticationServiceClient("WSHttpBinding_IAuthenticationService"); Session["value"] = "false"; Session["DocenteModulo"] = "deshabilitado"; LoginForm.Focus(); }
public Authentication(Uri APIUrl) { EndpointAddress endpoint = new EndpointAddress(APIUrl.ToString() + WSDL_LOCATIONS); if ("https".Equals(APIUrl.Scheme)) client = new AuthenticationServiceClient("BasicHttpBinding_IAuthenticationService11", endpoint); else if ("http".Equals(APIUrl.Scheme)) client = new AuthenticationServiceClient("BasicHttpBinding_IAuthenticationService", endpoint); }
public Entities.User GetById(int id) { using (var client = new AuthenticationServiceClient()) { AuthenticationService.User user = client.GetAll().ToList().First(authUser => authUser.Id == id); return(ServiceMapper.Mapper.Map <Entities.User>(user)); } }
private void RefreshProc() { // First login AuthenticationServiceClient authClient = new AuthenticationServiceClient(); string authToken = null; try { authToken = authClient.ValidateUser(m_user, m_pass); } catch (System.ServiceModel.EndpointNotFoundException) { authClient.Close(); m_onComplete(this, new OSBLEStateEventArgs(false, "Could not connect to the OSBLE server. " + "Please contact support if this problem persists.")); return; } authClient.Close(); authClient = null; if (string.IsNullOrEmpty(authToken)) { m_onComplete(this, new OSBLEStateEventArgs(false, "Could not log in to OSBLE. " + "Please check your user name and password.")); return; } // Now get a list of courses OsbleServiceClient osc = new OsbleServiceClient(); m_courses = osc.GetCourses(authToken); // Make sure we got some courses if (null == m_courses || 0 == m_courses.Length) { m_onComplete(this, new OSBLEStateEventArgs(false, "No courses were found for this user.")); return; } // Go through the courses and find out this user's role List <Course> canBeGraded = new List <Course>(); foreach (Course c in m_courses) { CourseRole cr = osc.GetCourseRole(c.ID, authToken); if (cr.CanGrade) { canBeGraded.Add(c); } } m_courses = canBeGraded.ToArray(); // Success if we made it this far m_onComplete(this, new OSBLEStateEventArgs(true, string.Empty)); }
private async void dataGridViewSearch_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3 && e.RowIndex < dataGridViewSearch.RowCount && e.RowIndex >= 0) { ClientUser clientUser = (ClientUser)dataGridViewSearch.Rows[e.RowIndex].DataBoundItem; User user = MapToServiceUser(clientUser); EditUserForm form = new EditUserForm(user, _user); if (form.ShowDialog(this) == DialogResult.OK) { dataGridViewSearch.Rows[e.RowIndex].Cells[0].Value = user.Login; dataGridViewSearch.Rows[e.RowIndex].Cells[1].Value = user.FullName; dataGridViewSearch.Rows[e.RowIndex].Cells[2].Value = user.Roles.First().RoleName; } } else if (e.ColumnIndex == 4 && e.RowIndex < dataGridViewSearch.RowCount && e.RowIndex >= 0) { ClientUser clientUser = (ClientUser)dataGridViewSearch.Rows[e.RowIndex].DataBoundItem; if (clientUser.Id == _user.Id) { MessageBox.Show(this, "You can not delete yourself!"); return; } User user = MapToServiceUser(clientUser); DialogResult dialogResult = MessageBox.Show( this, string.Format("Are you sure to delete '{0}' user?", user.FullName), "Delete user", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); if (dialogResult == DialogResult.Yes) { try { AuthenticationServiceClient client = new AuthenticationServiceClient(); Form frm = new ProgressForm(); frm.Show(); OperationResult serviceResult = await client.DeleteUserAsync(user); frm.Close(); if (!serviceResult.Success) { MessageBox.Show(this, "Users not found!"); } else { dataGridViewSearch.Rows.RemoveAt(e.RowIndex); } } catch (FaultException exc) { MessageBox.Show(exc.Message); } } } }
public ActionResult EditUser(UserViewModel user) { using (var admin = new AuthenticationServiceClient()) { Mapper.Initialize(o => o.CreateMap <UserViewModel, AuthenticationService.UserDataContract>()); var userEdit = Mapper.Map <UserViewModel, AuthenticationService.UserDataContract> (user); admin.EditUser(userEdit); } return(RedirectToAction("Index", "Admin")); }
private void RefreshThreadProc(object parameter) { // The parameter is the event handler for completion //EventHandler onCompletion = parameter as EventHandler; AuthenticationServiceClient auth = new AuthenticationServiceClient(); auth.ValidateUserCompleted += this.AuthForLoadCompleted; auth.ValidateUserAsync(m_userName, m_password, new object[] { auth, parameter }); }
public VIISPServiceOperations() { AuthenticationServiceClient client = new AuthenticationServiceClient("ExternalAuthenticationServiceImplPort"); client.Endpoint.Behaviors.Add( new SimpleEndpointBehavior() ); client.Open(); proxy = client; }
public ActionResult Groups() { IEnumerable <GroupViewModel> groups = new List <GroupViewModel>(); using (var admin = new AuthenticationServiceClient()) { Mapper.Initialize(o => o.CreateMap <AuthenticationService.GroupDataContract, GroupViewModel>()); groups = Mapper.Map <IEnumerable <AuthenticationService.GroupDataContract>, IEnumerable <GroupViewModel> >(admin.GetGroups()); } return(View(groups)); }
public bool ValidateToken(string token, bool validateUserId, string userId, string locale, string client) { bool isValid = false; try { if (Provider.SSO.SSOProvider.UseSSO(locale, client)) { if (Provider.SSO.SSOProvider.IsValidUser(userId)) { isValid = Provider.SSO.SSOProvider.ValidDistributor(token); } else if (client.ToLower().Equals("ikiosk")) { using (AuthenticationServiceClient proxy = MyHerbalife3.Core.AuthenticationProvider.Providers.UserAuthenticator.GetAuthServiceClient(true)) { var request = new GetDistributorIDByAuthTokenRequest_V02 { Token = token, IsCnMobileAuthToken = true }; var response = proxy.GetDistributorIDByAuthToken(request) as GetDistributorIDByAuthTokenResult_V02; if (response != null) { if (response.Status == ServiceResponseStatusType.Success && (!validateUserId || response.DistributorID == userId)) { return(isValid = true); } } } } } else { using (AuthenticationServiceClient proxy = MyHerbalife3.Core.AuthenticationProvider.Providers.UserAuthenticator.GetAuthServiceClient(true)) { var request = new GetDistributorIDByAuthTokenRequest_V02 { Token = token, IsCnMobileAuthToken = true }; var response = proxy.GetDistributorIDByAuthToken(request) as GetDistributorIDByAuthTokenResult_V02; if (response != null) { if (response.Status == ServiceResponseStatusType.Success && (!validateUserId || response.DistributorID == userId)) { return(isValid = true); } } } } return(isValid); } catch { return(isValid); } }
public AuthenticateResult Authenticate(UserCredentials userCredential) { Credentials credentials = new Credentials { UserName = userCredential.UserName, Password = userCredential.Password }; AuthenticationServiceClient authenticateService = new AuthenticationServiceClient(); return(Mapper.Map <AuthenticateResult>(authenticateService.Authenticate(credentials))); }
public ActionResult Index() { using (var admin = new AuthenticationServiceClient()) { var isAdmin = admin.UserInGroup(User.Identity.Name, "Administrator"); if (isAdmin) { return(View()); } } return(RedirectToAction("Catalog", "Home")); }
private void AuthClient_GetActiveUserCompleted(object sender, GetActiveUserCompletedEventArgs e) { // The authentication client has delivered what we need and so we can close it AuthenticationServiceClient authClient = e.UserState as AuthenticationServiceClient; authClient.CloseAsync(); if (null == e.Error) { m_userID = e.Result.ID; } }
private void ApplicationBarIconButtonSave_Click(object sender, EventArgs e) { Uri tempUri; if (String.IsNullOrEmpty(ServiceUrl.Text) || String.IsNullOrEmpty(Username.Text) || String.IsNullOrEmpty(Password.Password) || !Uri.TryCreate(ServiceUrl.Text, UriKind.Absolute, out tempUri)) { MessageBox.Show("Some data is missing. Verify all inputs."); return; } ShowProgress(); Settings.CachedAuthenticationToken = null; AuthenticationServiceClient authenticationService = new AuthenticationServiceClient( GetBinding(), new EndpointAddress(String.Format(CultureInfo.InvariantCulture, "{0}/Authentication/basic", ServiceUrl.Text))); authenticationService.AuthenticateCompleted += (o1, e1) => { if (e1.Error != null) { HideProgress(); MessageBox.Show(e1.Error.Message); } else { Settings.CachedAuthenticationToken = e1.Result.AuthenticationToken; Dictionary <string, string> endpoints = new Dictionary <string, string>(); foreach (var ae in e1.Result.AvailableEndpoints) { endpoints.Add(ae.Name, ae.BasicUrl); } Settings.Endpoints = endpoints; Settings.ServiceUrl = ServiceUrl.Text; Settings.Username = Username.Text; Settings.Password = Password.Password; Settings.Save(); HideProgress(); NavigationService.GoBack(); } }; authenticationService.AuthenticateAsync(Username.Text, Password.Password); }
protected void Page_Load(object sender, EventArgs e) { if (Session["rol"] != null) { int rol = int.Parse((string)Session["rol"]); switch (rol) { case 1: string nombreUsuario = string.Empty; string rolUsuario = string.Empty; string logIn = (string)Session["Cuenta"]; string Password = (string)Session["Contraseña"]; proxyAuthent = new AuthenticationServiceClient("WSHttpBinding_IAuthenticationService"); UserID = proxyAuthent.GetID(logIn, Password); if (UserID != 0) { nombreUsuario = proxyAuthent.GetPerson(UserID); rolUsuario = proxyAuthent.GetRole(1); lbl_welcome.Text = rolUsuario + ": " + nombreUsuario + " "; Session["value"] = "false"; //Session["DocenteModulo"] = "deshabilitado"; } else { Response.Redirect("Authentication.aspx"); } break; case 2: break; case 3: Response.Redirect("MenuDocente.aspx"); break; case 4: Response.Redirect("CalificacionesEstudiante.aspx"); break; } } else { Response.Redirect("Authentication.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { //userid = (long)Session["UserID"]; proxy = new AuthenticationServiceClient("WSHttpBinding_IAuthenticationService"); login = (string)Session["Cuenta"]; pass = (string)Session["Contraseña"]; long UserID = proxy.GetID(login, pass); //long userid = long.Parse((string)Session["UserID"]); Nombre(UserID); Reporte(UserID); Totales(UserID); }
//public ICommand EnterKeyCommand; public LoginPage() { InitializeComponent(); SessionManager.Session["user"] = null; HtmlPage.Plugin.Focus(); this.txtUsername.Focus(); _service = new AuthenticationServiceClient(); _service.AuthenticateCompleted += AuthenticateCompleted; //EnterKeyCommand = new RelayCommand<KeyEventArgs>(EnterKeyCommand_Execute); }
public bool Authenticate(string username, string password) { var middlewareService = new AuthenticationServiceClient(); middlewareService.ClientCredentials.Windows.ClientCredential.UserName = "******"; middlewareService.ClientCredentials.Windows.ClientCredential.Password = "******"; if (middlewareService.CheckExistence(username)) { return(middlewareService.Authenticate(username, password)); } return(false); }
public bool Login(string username, string password, string customCredential, bool isPersistent) { AuthenticationServiceClient proxy = new AuthenticationServiceClient(); using (new OperationContextScope(proxy.InnerChannel)) { bool result = proxy.Login(username, password, customCredential, isPersistent); var responseMessageProperty = (HttpResponseMessageProperty) OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name]; if (result) { HttpContext.Current.Session["cookieHolder"] = responseMessageProperty.Headers.Get("Set-Cookie"); } return result; } }
/// <summary> /// The index action. /// </summary> /// <returns>The index view.</returns> public ActionResult Index() { // Pull any data from a redirect into model state SyncTempDataWithModelState(); // Get the collection of users in the database GetUsersResponse response; using (var client = new AuthenticationServiceClient()) { response = client.GetAllUsers(new GetUsersRequest()); } // Return the index view with the users return View(response.Users); }
public static ValidationResult AuthenticateUser(string userName, string password) { var client = new AuthenticationServiceClient("WSHttpBinding_IAuthenticationService"); var userDetails = new UserDetails() { UserName = userName, Password = password }; var authenticationResultWithGroups = client.AuthenticateUserAndGetGroupMemberships(userDetails); if (authenticationResultWithGroups.IsAuthenticated) { var authorizedDepartments = ConfigurationManager.AppSettings["AuthorizedDepartments"]; var authorizedDepartmentsForApp = authorizedDepartments.Split(',').Select(c => c.ToLower()); var groupsOfUser = authenticationResultWithGroups.ListOfADGroups.ToList(); if (!groupsOfUser.Any(c => authorizedDepartmentsForApp.Contains(c.ToLower()))) { authenticationResultWithGroups.IsAuthenticated = false; authenticationResultWithGroups.ErrorOccured = true; authenticationResultWithGroups.ErrorMessage = "You are not authorized to use this application."; } } return authenticationResultWithGroups; }
public AuthSvc() { Client = new AuthenticationServiceClient("BasicHttpBinding_IAuthenticationService"); }
public static string OsbleLogin(string username, string password) { AuthenticationService authClient = new AuthenticationServiceClient(); return authClient.ValidateUser(username, password); }