Exemplo n.º 1
0
        public bool CreateUser(HttpServerUtility httpServer, ArrayList valueList)
        {
            //uservalueList.Add(ViewState["EmailAddress"].ToString());
            //uservalueList.Add(ViewState["FirstName"].ToString());
            //uservalueList.Add(ViewState["LastName"].ToString());
            //uservalueList.Add(ViewState["Password1"].ToString());
            //uservalueList.Add(ViewState["Password2"].ToString());
            DataAccessUtility dau             = new DataAccessUtility();
            ArrayList         paramAppList    = new ArrayList();
            DateTime          current         = DateTime.Now;
            string            xmlAppPath      = "ApplicationSettings//ApplicationSetting[Key = \"ApplicationName\"]";
            string            xmlAppName      = dau.GetKeyValue(httpServer, xmlAppPath);
            string            getappProcKey   = "SqlConnections//SqlConnection//SqlProcedures//SqlProcedure[Key = \"GetApplicationId\"]";
            string            xmlGetAppidProc = dau.GetKeyValue(httpServer, getappProcKey);

            paramAppList.Add(CreateParamArray("@ApplicationName", xmlAppName));
            paramAppList.Add(CreateParamArray("@ApplicationId", ""));

            Guid resultGuid = dau.ExecuteProcedureGuid(httpServer, "SecurityConnectionString", xmlGetAppidProc, paramAppList, "@ApplicationId");

            //DataView resultView = dau.ExecuteProcedure(httpServer, "SecurityConnectionString", xmlGetAppidProc, paramAppList);

            //string getUserCreateProcKey = "SqlConnections//SqlConnection//SqlProcedures//SqlProcedure[Key = \"CreateUsersUser\"]";
            //string xmlGetUserCreateProc = dau.GetKeyValue(httpServer, getUserCreateProcKey);
            //Guid appidGuid = (Guid)resultView.Table.Rows[0].ItemArray[0];
            //ArrayList createUserList = new ArrayList();
            //createUserList.Add(CreateParamArray("@ApplicationId", appidGuid));
            //createUserList.Add(CreateParamArray("@UserName", valueList[0].ToString()));
            //createUserList.Add(CreateParamArray("@IsUserAnonymous", 0));
            //createUserList.Add(CreateParamArray("@LastActivityDate", current.ToString()));
            //createUserList.Add(CreateParamArray("@UserId", Guid.Empty));
            //DataView userView = dau.ExecuteProcedure(httpServer, "SecurityConnectionString", xmlGetUserCreateProc, createUserList);



            return(false);
        }
Exemplo n.º 2
0
        public string[] GetAllRoles(HttpServerUtility serverUtil)
        {
            string[]          allRoles       = { "" };
            DataAccessUtility dau            = new DataAccessUtility();
            string            getpassProcKey = "SqlConnections//SqlConnection//SqlProcedures//SqlProcedure[Key = \"GetAllRoles\"]";
            string            xmlGetPassProc = dau.GetKeyValue(serverUtil, getpassProcKey);
            string            xmlAppPath     = "ApplicationSettings//ApplicationSetting[Key = \"ApplicationName\"]";
            string            xmlAppName     = dau.GetKeyValue(serverUtil, xmlAppPath);
            ArrayList         getroleArray   = new ArrayList();
            ArrayList         alApp          = new ArrayList();

            alApp.Add("@ApplicationName");
            alApp.Add(xmlAppName);
            alApp.Add(SqlDbType.NVarChar);
            getroleArray.Add(alApp);
            DataView roleView = dau.ExecuteProcedureDataView(serverUtil, "SecurityConnectionString", xmlGetPassProc, getroleArray);

            allRoles = new string[roleView.Table.Rows.Count];
            for (int i = 0; i < roleView.Table.Rows.Count; i++)
            {
                allRoles[i] = roleView.Table.Rows[i].ItemArray[0].ToString();
            }
            return(allRoles);
        }
Exemplo n.º 3
0
        public void ValidateUser(HttpServerUtility httpServer, string username, string password)
        {
            bool              IsUserValid    = false;
            string            xmlAppPath     = "ApplicationSettings//ApplicationSetting[Key = \"ApplicationName\"]";
            string            getuserProcKey = "SqlConnections//SqlConnection//SqlProcedures//SqlProcedure[Key = \"GetUserByName\"]";
            DataAccessUtility dau            = new DataAccessUtility();
            string            xmlAppName     = dau.GetKeyValue(httpServer, xmlAppPath);
            string            xmlGetUserProc = dau.GetKeyValue(httpServer, getuserProcKey);
            DateTime          currentUtc     = new DateTime();

            currentUtc = DateTime.UtcNow;
            int       updateActvty = 1;
            ArrayList getuserArray = new ArrayList();
            ArrayList alApp        = new ArrayList();

            alApp.Add("@ApplicationName");
            alApp.Add(xmlAppName);
            alApp.Add(SqlDbType.NVarChar);
            getuserArray.Add(alApp);
            ArrayList alUser = new ArrayList();

            alUser.Add("@UserName");
            alUser.Add(username);
            alUser.Add(SqlDbType.NVarChar);
            getuserArray.Add(alUser);
            ArrayList alUtc = new ArrayList();

            alUtc.Add("@CurrentTimeUtc");
            alUtc.Add(currentUtc);
            alUtc.Add(SqlDbType.DateTime);
            getuserArray.Add(alUtc);
            ArrayList alAct = new ArrayList();

            alAct.Add("@UpdateLastActivity");
            alAct.Add(updateActvty);
            alAct.Add(SqlDbType.Int);
            getuserArray.Add(alAct);
            DataView userView = dau.ExecuteProcedureDataView(httpServer, "SecurityConnectionString", xmlGetUserProc, getuserArray);

            if (!(userView == null))
            {
                UserIdentity.Comment                 = userView.Table.Rows[0].ItemArray[2].ToString();
                UserIdentity.CreateDate              = Convert.ToDateTime(userView.Table.Rows[0].ItemArray[4]);
                UserIdentity.UserEmail               = userView.Table.Rows[0].ItemArray[0].ToString();
                UserIdentity.IsLockedOut             = Convert.ToBoolean(userView.Table.Rows[0].ItemArray[9]);
                UserIdentity.LastLockoutDate         = Convert.ToDateTime(userView.Table.Rows[0].ItemArray[10]);
                UserIdentity.LastPasswordChangedDate = Convert.ToDateTime(userView.Table.Rows[0].ItemArray[7]);
                UserIdentity.PasswordQuestion        = userView.Table.Rows[0].ItemArray[1].ToString();
                UserIdentity.UserIdentification      = (Guid)userView.Table.Rows[0].ItemArray[8];
            }
            string getpassProcKey = "SqlConnections//SqlConnection//SqlProcedures//SqlProcedure[Key = \"GetPasswordWithFormat\"]";
            string xmlGetPassProc = dau.GetKeyValue(httpServer, getpassProcKey);

            getuserArray.Remove(alAct);
            ArrayList alLog = new ArrayList();

            alLog.Add("@UpdateLastLoginActivityDate");
            alLog.Add(updateActvty);
            alLog.Add(SqlDbType.Int);
            getuserArray.Add(alLog);
            DataView passView = dau.ExecuteProcedureDataView(httpServer, "SecurityConnectionString", xmlGetPassProc, getuserArray);

            if (!(passView == null))
            {
                UserIdentity.FailedPasswordAnswerAttemptCount = Convert.ToInt32(passView.Table.Rows[0].ItemArray[4]);
                UserIdentity.FailedPasswordAttemptCount       = Convert.ToInt32(passView.Table.Rows[0].ItemArray[3]);
                UserIdentity.IsApproved       = Convert.ToBoolean(passView.Table.Rows[0].ItemArray[5]);
                UserIdentity.LastActivityDate = Convert.ToDateTime(passView.Table.Rows[0].ItemArray[7]);
                UserIdentity.LastLoginDate    = Convert.ToDateTime(passView.Table.Rows[0].ItemArray[6]);
                UserIdentity.Password         = passView.Table.Rows[0].ItemArray[0].ToString();
                UserIdentity.PasswordFormat   = Convert.ToInt32(passView.Table.Rows[0].ItemArray[1]);
                UserIdentity.PasswordSalt     = passView.Table.Rows[0].ItemArray[2].ToString();
            }
            //**********************unencrypt db password and validate against user password;

            string    getroleProcKey = "SqlConnections//SqlConnection//SqlProcedures//SqlProcedure[Key = \"GetRolesForUser\"]";
            string    xmlGetRoleProc = dau.GetKeyValue(httpServer, getroleProcKey);
            ArrayList getroleArray   = new ArrayList();

            getroleArray.Add(alApp);
            getroleArray.Add(alUser);
            DataView roleView = dau.ExecuteProcedureDataView(httpServer, "SecurityConnectionString", xmlGetRoleProc, getroleArray);

            if (!(roleView == null))
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < roleView.Table.Rows.Count; i++)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append(roleView.Table.Rows[0].ItemArray[i].ToString());
                }
                UserIdentity.UserRoles = sb.ToString();
            }
            return;
        }