コード例 #1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="row"></param>
        public OuUsers(DataRow row)
        {
            _StrOUGuid          = OGUCommonDefine.DBValueToString(row["PARENT_GUID"]);
            _StrUserGuid        = OGUCommonDefine.DBValueToString(row["USER_GUID"]);
            _StrUserDisplayName = OGUCommonDefine.DBValueToString(row["DISPLAY_NAME"]);
            _StrUserObjName     = OGUCommonDefine.DBValueToString(row["OBJ_NAME"]);
            _StrInnerSort       = OGUCommonDefine.DBValueToString(row["INNER_SORT"]);
            _StrOriginalSort    = OGUCommonDefine.DBValueToString(row["ORIGINAL_SORT"]);
            _StrGlobalSort      = OGUCommonDefine.DBValueToString(row["GLOBAL_SORT"]);
            _StrAllPathName     = OGUCommonDefine.DBValueToString(row["ALL_PATH_NAME"]);
            _StrUserDescription = OGUCommonDefine.DBValueToString(row["DESCRIPTION"]);

            if ((int)row["SIDELINE"] == 0)
            {
                _BSideline = false;
            }

            if (row["START_TIME"] is DBNull)
            {
                _StartTime = System.DateTime.MinValue;
            }
            else
            {
                _StartTime = (DateTime)row["START_TIME"];
            }

            if (row["END_TIME"] is DBNull)
            {
                _EndTime = DateTime.MaxValue;
            }
            else
            {
                _EndTime = (DateTime)row["END_TIME"];
            }
        }
コード例 #2
0
        //public SearchOrgChildrenCondition(string strRootValues, SearchObjectColumn soc, string strAttrs, DataAccess da)
        //{
        //    string strRootGuids = string.Empty;
        //    if (strRootValues.Length > 0 && soc != SearchObjectColumn.SEARCH_GUID)
        //    {
        //			DataSet ds = OGUReader.GetObjectsDetail("ORGANIZATIONS",
        //				strRootValues,
        //				soc,
        //				string.Empty,
        //				SearchObjectColumn.SEARCH_NULL,
        //				string.Empty,
        //				da);
        //        foreach (DataRow row in ds.Tables[0].Rows)
        //        {
        //            if (strRootGuids.Length > 0)
        //                strRootGuids += ",";
        //            strRootGuids += XmlHelper.DBValueToString(row["GUID"]);
        //        }
        //    }
        //    else
        //        strRootGuids = strRootValues;

        //    InitSearchOrgChildrenCondition(strRootGuids, strAttrs, da);
        //}

        #endregion

        #region Private Function Define
        private void InitSearchOrgChildrenCondition(string strRootGuids, string strAttrs, bool isNeedDefault)
        {
            using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias))
            {
                Database database = DatabaseFactory.Create(context);
                if (0 == strRootGuids.Length && true == isNeedDefault)
                {
                    strRootGuids = OGUReader.GetRootDSE().Tables[0].Rows[0]["GUID"].ToString();
                }

                string[] strRoots = strRootGuids.Split(',');
                _HashRoot = new SortedList <string, string>();               // new Hashtable();
                for (int i = 0; i < strRoots.Length; i++)
                {
                    _HashRoot.Add(strRoots[i], strRoots[i]);
                }

                strAttrs     = OGUCommonDefine.CombinateAttr(strAttrs);
                _StrObjAttrs = strAttrs;
            }
        }
コード例 #3
0
        /// <summary>
        /// 根据查询结果ds中数据值来初始化当前对象对应的各个属性数据
        /// </summary>
        /// <param name="ds">针对用户信息的查询结果</param>
        private void InitData(DataSet ds)
        {
            DataTable table = ds.Tables[0];

            ExceptionHelper.TrueThrow <ApplicationException>(table.Rows.Count == 0,
                                                             "对不起, 系统中没有找到与\"" + _StrUserLogOnName + "\"对应的有效帐号!\n请输入正确的用户名和口令!");

            DataRow row = table.Rows[0];

            _StrUserGuid      = OGUCommonDefine.DBValueToString(row["USER_GUID"]);
            _StrUserLogOnName = OGUCommonDefine.DBValueToString(row["LOGON_NAME"]);
            _RankDefine       = new RankDefine(OGUCommonDefine.DBValueToString(row["RANK_CODE"]),
                                               (int)row["SORT_ID"], OGUCommonDefine.DBValueToString(row["NAME"]), (int)row["VISIBLE"]);
            _OuUsers = new IOuUsers[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                _OuUsers[i] = new OuUsers(table.Rows[i]);
            }

            _IIdentity = new GenericIdentity(_StrUserLogOnName);
        }
コード例 #4
0
        /// <summary>
        /// 用户修改口令接口
        /// </summary>
        /// <param name="strUserValue">要求被修改口令的用户</param>
        /// <param name="socu">strUserValue对应的数据类型</param>
        /// <param name="strOldPwd">用户的旧口令</param>
        /// <param name="strNewPwd">使用的新口令</param>
        /// <param name="strConfirmPwd">新口令的确认</param>
        /// <returns>本次修改是否成功</returns>
        public bool UpdateUserPwd(string strUserValue, SearchObjectColumn socu, string strOldPwd, string strNewPwd, string strConfirmPwd)
        {
            ExceptionHelper.TrueThrow(string.IsNullOrEmpty(strNewPwd.Trim()), "对不起,用户的登录口令不能为空!");
            ExceptionHelper.FalseThrow(strNewPwd == strConfirmPwd, "对不起,用户的“新口令”必须与“确认口令”一致!");

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias))
                {
                    Database database = DatabaseFactory.Create(context);

                    string strUserColName = OGUCommonDefine.GetSearchObjectColumn(socu);
                    string strSql         = @"SELECT USERS.GUID 
				FROM USERS, OU_USERS
				WHERE USERS.GUID = OU_USERS.USER_GUID
					AND "                     + DatabaseSchema.Instence.GetTableColumns(strUserColName, "USERS")
                                            + " = " + TSqlBuilder.Instance.CheckQuotationMark(strUserValue, true) + @";
				SELECT TOP 1 GUID FROM PWD_ARITHMETIC WHERE VISIBLE = 1 ORDER BY SORT_ID;"                ;

                    DataSet ds = database.ExecuteDataSet(CommandType.Text, strSql);

                    ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count == 0, "对不起,系统中没有找到您指定的用户!");
                    ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count > 1, "对不起,您指定的用户在系统中不唯一!");
                    ExceptionHelper.TrueThrow(ds.Tables[1].Rows.Count < 1, "对不起,系统中找的不到数据表PWD_ARITHMETIC的数据!");
                    string secNewPwd = SecurityCalculate.PwdCalculate(ds.Tables[1].Rows[0][0].ToString(), strNewPwd);
                    string secOldPwd = SecurityCalculate.PwdCalculate(ds.Tables[1].Rows[0][0].ToString(), strOldPwd);

                    strSql = "UPDATE USERS SET USER_PWD = "
                             + TSqlBuilder.Instance.CheckQuotationMark(secNewPwd, true) + @"
				WHERE USERS.GUID = "                 + TSqlBuilder.Instance.CheckQuotationMark((string)ds.Tables[0].Rows[0]["GUID"], true) + @"
					AND USERS.USER_PWD = "
                             + TSqlBuilder.Instance.CheckQuotationMark(secOldPwd, true);

                    ExceptionHelper.FalseThrow(database.ExecuteNonQuery(CommandType.Text, strSql) == 1, "对不起,用户的旧口令不正确!");
                }
                scope.Complete();
            }
            return(true);
        }