コード例 #1
0
ファイル: SignIn.aspx.cs プロジェクト: skyquery/graywulf
        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;
            }
        }
コード例 #2
0
ファイル: User.aspx.cs プロジェクト: skyquery/graywulf
 protected void DuplicateEmailValidator_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (RegistryUser == null)
     {
         var ef = new UserFactory(RegistryContext);
         args.IsValid = !ef.CheckEmailDuplicate(Domain, args.Value.Trim());
     }
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
ファイル: Activate.aspx.cs プロジェクト: skyquery/graywulf
        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;
            }
        }
コード例 #5
0
ファイル: SignIn.aspx.cs プロジェクト: horvatferi/graywulf
        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;
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        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");
                }
            }
        }
コード例 #8
0
ファイル: Parameters.cs プロジェクト: skyquery/graywulf
        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);
        }
コード例 #9
0
ファイル: SignIn.aspx.cs プロジェクト: skyquery/graywulf
        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;
            }
        }
コード例 #10
0
ファイル: GraywulfIdentity.cs プロジェクト: skyquery/graywulf
        /// <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;
                }
            }
        }
コード例 #11
0
ファイル: Parameters.cs プロジェクト: horvatferi/graywulf
 protected void SignIn(Cluster cluster)
 {
     var uu = new UserFactory(cluster.Context);
     uu.LoginUser(cluster, userName, password);
 }
コード例 #12
0
ファイル: TestClassBase.cs プロジェクト: horvatferi/graywulf
        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");
        }