protected void PasswordValidator_ServerValidate(object source, ServerValidateEventArgs args) { // Attempt to log in with supplied credentials try { var cluster = new Registry.Cluster(RegistryContext); cluster.Guid = new Guid(ClusterList.SelectedValue); cluster.Load(); cluster.LoadDomains(false); var domain = cluster.Domains[Registry.Constants.SharedDomainName]; var uu = new UserFactory(RegistryContext); user = uu.LoginUser(domain, Username.Text, Password.Text); RegistryContext.UserGuid = user.Guid; RegistryContext.UserName = user.Name; args.IsValid = true; } catch (EntityNotFoundException) { args.IsValid = false; } }
protected void DuplicateEmailValidator_ServerValidate(object source, ServerValidateEventArgs args) { if (RegistryUser == null) { var ef = new UserFactory(RegistryContext); args.IsValid = !ef.CheckEmailDuplicate(Domain, args.Value.Trim()); } }
protected void OldPasswordValidator_ServerValidate(object source, ServerValidateEventArgs args) { if (RegistryUser != null) { var uu = new UserFactory(RegistryContext); args.IsValid = uu.LoginUser(Domain, user.Name, OldPassword.Text) != null; } else { args.IsValid = false; } }
private bool ActivateUser(string code) { try { var uu = new UserFactory(RegistryContext); user = uu.FindUserByActivationCode(Domain, code); user.ActivationCode = string.Empty; user.DeploymentState = DeploymentState.Deployed; user.Save(); return true; } catch (EntityNotFoundException) { return false; } }
protected void PasswordValidator_ServerValidate(object source, ServerValidateEventArgs args) { // Attempt to log in with supplied credentials try { var uu = new UserFactory(RegistryContext); user = uu.LoginUser(Domain, Username.Text, Password.Text); RegistryContext.UserGuid = user.Guid; RegistryContext.UserName = user.Name; args.IsValid = true; } catch (Exception ex) { LogError(ex); args.IsValid = false; } }
protected void EmailValidator_ServerValidate(object source, ServerValidateEventArgs args) { try { var uu = new UserFactory(RegistryContext); var user = uu.FindUserByEmail(Domain, args.Value); user.GenerateActivationCode(); user.Save(); Util.EmailSender.Send(user, File.ReadAllText(MapPath("~/Templates/RequestResetEmail.xml")), BaseUrl); args.IsValid = true; } catch (EntityNotFoundException) { args.IsValid = false; } }
protected void Page_Load(object sender, EventArgs e) { if (RegistryUser != null) { OldPasswordRow.Visible = true; user = RegistryUser; } else { OldPasswordRow.Visible = false; // Load user try { var uu = new UserFactory(RegistryContext); uu.FindUserByActivationCode(Domain, Request.QueryString["code"]); } catch (EntityNotFoundException) { throw new Registry.SecurityException("Access denied"); } } }
protected void SignIn(Cluster cluster) { cluster.LoadDomains(false); var domain = cluster.Domains[Constants.SharedDomainName]; var uu = new UserFactory(cluster.Context); uu.LoginUser(domain, userName, password); }
private void LoginUser() { // Load user from the registry var uu = new UserFactory(RegistryContext); user = uu.LoginUser(Domain, Username.Text, Password.Text); RegistryContext.UserGuid = user.Guid; RegistryContext.UserName = user.Name; // If there's any temporary identifier set, associate // with the user if (TemporaryPrincipal != null) { var identity = (GraywulfIdentity)TemporaryPrincipal.Identity; var ui = identity.CreateUserIdentity(user); ui.Save(); TemporaryPrincipal = null; } }
/// <summary> /// Loads the user from the graywulf registry /// </summary> /// <param name="identity"></param> /// <remarks> /// If the identity is not found, it will be marked as non-authenticated /// </remarks> public void LoadUser(Domain domain) { using (var registryContext = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit)) { var uf = new UserFactory(registryContext); try { switch (protocol) { case Constants.ProtocolNameForms: userProperty.Value = uf.LoadUser(identifier); break; case Constants.ProtocolNameWindows: // TODO: implement NTLM auth throw new NotImplementedException(); default: // All other cases use lookup by protocol name userProperty.Value = uf.FindUserByIdentity(domain, protocol, authorityUri, identifier); break; } IsAuthenticated = true; } catch (EntityNotFoundException) { isAuthenticated = false; } } }
protected void SignIn(Cluster cluster) { var uu = new UserFactory(cluster.Context); uu.LoginUser(cluster, userName, password); }
protected User SignInTestUser(Context context) { // TODO: throw exception on logon failure var ef = new EntityFactory(context); //var c = ef.LoadEntity<Cluster>(Cluster.AppSettings.ClusterName); var d = ef.LoadEntity<Domain>(Domain.AppSettings.DomainName); var uu = new UserFactory(context); return uu.LoginUser(d, "test", "alma"); }