コード例 #1
0
        private void InitializeOtherControls()
        {
            // Load MethodOfContact List
            PMethodOfContactTable MethodOfContactTable = (PMethodOfContactTable)TDataCache.TMPartner.GetCacheableMailingTable(
                TCacheableMailingTablesEnum.MethodOfContactList);

            cmbContact.Items.Add("*");

            foreach (PMethodOfContactRow Row in MethodOfContactTable.Rows)
            {
                cmbContact.Items.Add(Row.MethodOfContactCode);
            }

            cmbContact.SelectedIndex = 0;

            // Load User List
            SUserTable UserTable = (SUserTable)TDataCache.TMSysMan.GetCacheableSysManTable(TCacheableSysManTablesEnum.UserList);
            DataView   dvActive  = new DataView(UserTable);

            dvActive.RowFilter = string.Format("{0}=0 AND {1}=0", SUserTable.GetRetiredDBName(), SUserTable.GetAccountLockedDBName());
            dvActive.Sort      = string.Format("{0}", SUserTable.GetUserIdDBName());

            cmbContactor.Items.Add("*");

            foreach (DataRowView drv in dvActive)
            {
                SUserRow row = (SUserRow)drv.Row;
                cmbContactor.Items.Add(row.UserId);
            }

            cmbContactor.SelectedIndex = 0;
        }
コード例 #2
0
        private DataTable GetFoundationOwnerListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            // Used in Foundation Details screen.
            SUserTable TmpUserTable = new SUserTable();

            TmpUserTable = (SUserTable)DBAccess.GetDBAccessObj(AReadTransaction).SelectDT(TmpUserTable, "SELECT " +
                                                                                          SUserTable.GetPartnerKeyDBName() + ',' +
                                                                                          SUserTable.GetUserIdDBName() + ',' +
                                                                                          SUserTable.GetFirstNameDBName() + ',' +
                                                                                          SUserTable.GetLastNameDBName() + ' ' +
                                                                                          "FROM PUB_" + SUserTable.GetTableDBName() + ' ' +
                                                                                          "WHERE " + SUserTable.GetPartnerKeyDBName() + " <> 0 " +
                                                                                          "AND " + SUserTable.GetUserIdDBName() +
                                                                                          " IN (SELECT " + SUserModuleAccessPermissionTable.GetUserIdDBName() + ' ' +
                                                                                          "FROM PUB_" + SUserModuleAccessPermissionTable.GetTableDBName() + ' ' +
                                                                                          "WHERE " + SUserModuleAccessPermissionTable.GetModuleIdDBName() +
                                                                                          " = 'DEVUSER')" + "AND " + SUserTable.GetRetiredDBName() +
                                                                                          " = FALSE", AReadTransaction, null, -1, -1);
            SUserRow EmptyDR = TmpUserTable.NewRowTyped(false);

            EmptyDR.PartnerKey = 0;
            EmptyDR.UserId     = "";
            TmpUserTable.Rows.InsertAt(EmptyDR, 0);
            return(TmpUserTable);
        }
コード例 #3
0
ファイル: UserManagement.cs プロジェクト: lxhelp/openpetra
        public static TSubmitChangesResult SaveSUser(ref MaintainUsersTDS ASubmitDS,
                                                     string AClientComputerName, string AClientIPAddress)
        {
            TSubmitChangesResult ReturnValue = TSubmitChangesResult.scrError;
            TDBTransaction       SubmitChangesTransaction = null;
            bool             CanCreateUser;
            bool             CanChangePassword;
            bool             CanChangePermissions;
            int              PwdSchemeVersionUpTillNow;
            int              CurrentPwdSchemeVersion = TPasswordHelper.CurrentPasswordSchemeNumber;
            MaintainUsersTDS SubmitDS;

            SubmitDS = ASubmitDS;

            GetAuthenticationFunctionality(out CanCreateUser, out CanChangePassword, out CanChangePermissions);

            // make sure users are not deleted or added if this is not possible
            if (!CanCreateUser && (ASubmitDS.SUser != null))
            {
                Int32 Counter = 0;

                while (Counter < ASubmitDS.SUser.Rows.Count)
                {
                    if (ASubmitDS.SUser.Rows[Counter].RowState != DataRowState.Modified)
                    {
                        ASubmitDS.SUser.Rows.RemoveAt(Counter);
                    }
                    else
                    {
                        Counter++;
                    }
                }
            }

            if (!CanChangePermissions && (ASubmitDS.SUserModuleAccessPermission != null))
            {
                ASubmitDS.SUserModuleAccessPermission.Clear();
            }

            // TODO: if user module access permissions have changed, automatically update the table access permissions?

            DBAccess.SimpleAutoTransactionWrapper(IsolationLevel.Serializable, "SaveSUser", out SubmitChangesTransaction,
                                                  ref ReturnValue, delegate
            {
                if (SubmitDS.SUser != null)
                {
                    foreach (SUserRow user in SubmitDS.SUser.Rows)
                    {
                        // for new users: create users on the alternative authentication method
                        if (user.RowState == DataRowState.Added)
                        {
                            CreateUser(user.UserId, user.PasswordHash, user.FirstName, user.LastName, string.Empty,
                                       AClientComputerName, AClientIPAddress, SubmitChangesTransaction);
                            user.AcceptChanges();
                        }
                        else
                        {
                            PwdSchemeVersionUpTillNow = user.PwdSchemeVersion;

                            // Has the 'Account Locked' state changed?
                            if (Convert.ToBoolean(user[SUserTable.GetAccountLockedDBName(), DataRowVersion.Original]) != user.AccountLocked)
                            {
                                if (user.AccountLocked)
                                {
                                    TUserAccountActivityLog.AddUserAccountActivityLogEntry(user.UserId,
                                                                                           TUserAccountActivityLog.USER_ACTIVITY_USER_ACCOUNT_GOT_LOCKED,
                                                                                           String.Format(
                                                                                               StrUserChangedOtherUsersLockedState, UserInfo.GUserInfo.UserID,
                                                                                               user.UserId, Catalog.GetString("locked")) +
                                                                                           String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress),
                                                                                           SubmitChangesTransaction);
                                }
                                else
                                {
                                    TUserAccountActivityLog.AddUserAccountActivityLogEntry(user.UserId,
                                                                                           TUserAccountActivityLog.USER_ACTIVITY_USER_ACCOUNT_GOT_UNLOCKED,
                                                                                           String.Format(
                                                                                               StrUserChangedOtherUsersLockedState, UserInfo.GUserInfo.UserID,
                                                                                               user.UserId, Catalog.GetString("unlocked")) +
                                                                                           String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress),
                                                                                           SubmitChangesTransaction);

                                    // If the user account got locked when a Password Hashing Scheme was in place that isn't
                                    // the current one then require the user to change his/her password on next login. This is to
                                    // ensure that the Password Hash and Salt that gets placed in the s_user table record of this
                                    // user at his/her next logon isn't just the new Password Hash and Salt of the password that
                                    // the user had used when the user account got Locked (the Password Hashing Scheme of that user
                                    // will get upgraded to the current one then, but in case the system administrator locked the user
                                    // account because (s)he suspects a security breach then any future attempts to use the previous
                                    // password will be thwarted).
                                    if (PwdSchemeVersionUpTillNow != CurrentPwdSchemeVersion)
                                    {
                                        user.PasswordNeedsChange = true;
                                    }
                                }
                            }

                            // Has the 'Retired' state changed?
                            if (Convert.ToBoolean(user[SUserTable.GetRetiredDBName(), DataRowVersion.Original]) != user.Retired)
                            {
                                if (user.Retired)
                                {
                                    TUserAccountActivityLog.AddUserAccountActivityLogEntry(user.UserId,
                                                                                           TUserAccountActivityLog.USER_ACTIVITY_USER_GOT_RETIRED,
                                                                                           String.Format(
                                                                                               StrUserChangedOtherUsersRetiredState, UserInfo.GUserInfo.UserID,
                                                                                               user.UserId, Catalog.GetString("retired")) +
                                                                                           String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress),
                                                                                           SubmitChangesTransaction);
                                }
                                else
                                {
                                    TUserAccountActivityLog.AddUserAccountActivityLogEntry(user.UserId,
                                                                                           TUserAccountActivityLog.USER_ACTIVITY_USER_GOT_UNRETIRED,
                                                                                           String.Format(
                                                                                               StrUserChangedOtherUsersRetiredState, UserInfo.GUserInfo.UserID,
                                                                                               user.UserId, Catalog.GetString("no longer retired")) +
                                                                                           String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress),
                                                                                           SubmitChangesTransaction);

                                    // If the user account got retired when a Password Hashing Scheme was in place that isn't
                                    // the current one then require the user to change his/her password on next login. This is to
                                    // ensure that the Password Hash and Salt that gets placed in the s_user table record of this
                                    // user at his/her next logon isn't just the new Password Hash and Salt of the password that
                                    // the user had used when the user account got Retired (the Password Hashing Scheme of that user
                                    // will get upgraded to the current one then, but in case the system administrator retired the user
                                    // account because (s)he suspects a security breach then any future attempts to use the previous
                                    // password will be thwarted).
                                    if (PwdSchemeVersionUpTillNow != CurrentPwdSchemeVersion)
                                    {
                                        user.PasswordNeedsChange = true;
                                    }
                                }
                            }
                        }
                    }
                }

                try
                {
                    MaintainUsersTDSAccess.SubmitChanges(SubmitDS, SubmitChangesTransaction.DataBaseObj);

                    ReturnValue = TSubmitChangesResult.scrOK;
                }
                catch (Exception e)
                {
                    TLogging.Log(e.Message);
                    TLogging.Log(e.StackTrace);

                    throw;
                }
            });

            ASubmitDS = SubmitDS;

            return(ReturnValue);
        }