Beispiel #1
0
		public UsersDataAccess()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			manager = new UserRoleManager("CTPPDB",ConfigurationManager.GetCurrentContext());
		}
Beispiel #2
0
        public RoleForm(DbAuthenticationProviderData dbAuthenticationProviderData, ConfigurationContext context)
        {
            this.dbAuthenticationproviderData = dbAuthenticationProviderData;
            InitializeComponent();

            this.userRoleMgr = new UserRoleManager(dbAuthenticationProviderData.Database, context);

            UpdateSaveButtonEnabled();
        }
Beispiel #3
0
        public UserForm(DbAuthenticationProviderData dbAuthenticationProvider, ConfigurationContext context)
        {
            this.dbAuthenticationProvider = dbAuthenticationProvider;
            InitializeComponent();

            this.userRoleMgr = new UserRoleManager(dbAuthenticationProvider.Database, context);

            HashProviderFactory hashProviderFactory = new HashProviderFactory(context);
            this.hashProvider = hashProviderFactory.CreateHashProvider(dbAuthenticationProvider.HashProvider);
            UpdateSaveButtonEnabled();
        }
Beispiel #4
0
        /// <summary>
        /// Overridden from SecurityRolesProvider. Retrieves the list of user roles
        /// from the underlying database.
        /// </summary>
        /// <param name="userIdentity">Identity of user used for retrieval</param>
        /// <returns>String array of roles for the given user identity</returns>
        protected override string[] CollectAllUserRoles(IIdentity userIdentity)
        {
            //Copy each role name into a string array
            DbRolesProviderData dbRolesProviderData = (DbRolesProviderData)securityConfigurationView.GetRolesProviderData(ConfigurationName);
            UserRoleManager manager = new UserRoleManager(dbRolesProviderData.Database, securityConfigurationView.ConfigurationContext);
            DataSet dsRoles = manager.GetUserRoles(userIdentity.Name);

            StringBuilder tmpRoles = new StringBuilder();
            foreach (DataRow row in dsRoles.Tables[0].Rows)
            {
                tmpRoles.Append(row["RoleName"]);
                tmpRoles.Append(",");
            }

            return tmpRoles.ToString().TrimEnd(',').Split(',');
        }
Beispiel #5
0
        /// <summary>
        /// Overridden from SecurityRolesProvider. Retrieves the list of user roles
        /// from the underlying database.
        /// </summary>
        /// <param name="userIdentity">Identity of user used for retrieval</param>
        /// <returns>String array of roles for the given user identity</returns>
        protected override string[] CollectAllUserRoles(IIdentity userIdentity)
        {
            //Copy each role name into a string array
            DbRolesProviderData dbRolesProviderData = (DbRolesProviderData)securityConfigurationView.GetRolesProviderData(ConfigurationName);
            UserRoleManager     manager             = new UserRoleManager(dbRolesProviderData.Database, securityConfigurationView.ConfigurationContext);
            DataSet             dsRoles             = manager.GetUserRoles(userIdentity.Name);

            StringBuilder tmpRoles = new StringBuilder();

            foreach (DataRow row in dsRoles.Tables[0].Rows)
            {
                tmpRoles.Append(row["RoleName"]);
                tmpRoles.Append(",");
            }

            return(tmpRoles.ToString().TrimEnd(',').Split(','));
        }
Beispiel #6
0
        private void ConnectToDatabase()
        {
            this.gbxUserRoles.Enabled = false;
            string databaseInstance = this.DbAuthenticationProvider.Database;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                this.userRoleMgr = new UserRoleManager(databaseInstance, ConfigurationManager.GetCurrentContext());

                GetAllUsers();
                GetAllRoles();

                this.gbxUserRoles.Enabled = true;
            }
            catch(Exception e)
            {
                string msg = SR.NoDatabaseExceptionMessage(paragraphSeparator, paragraphSeparator, paragraphSeparator, e.Message);
                MessageBox.Show(msg, SR.DatabaseConnectionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #7
0
		protected virtual void Dispose(bool disposing)
		{
			if (! disposing)
				return; 

			if (manager != null)
			{
				manager = null;
			}
		}