Example #1
0
        public KeystoneAuthDataV41 GetAuthData(DefaultDataContract msg)
        {
            CPContext          context      = CPContext.Current;
            string             loginName    = null;
            string             domain       = null;
            string             userName     = context.GetUserName(out loginName, out domain);
            string             languageCode = msg.Header.Language;
            AuthApplicationMsg application  = new AuthApplicationMsg()
            {
                Id              = CPConfig.Application.Id,
                Name            = CPConfig.Application.Name,
                DefaultLanguage = CPConfig.Application.DefaultLanguage,
            };
            List <KS_ApplicationMsg>      ks_applications = new List <KS_ApplicationMsg>();
            KeystoneApplicationCollection applications    = CPConfig.Keystone.Applications;

            if (applications != null)
            {
                foreach (KeystoneApplicationElement app in applications)
                {
                    ks_applications.Add(new KS_ApplicationMsg()
                    {
                        Id   = app.Id,
                        Name = app.Name
                    });
                }
            }
            KeystoneAuthDataV41 result = new KeystoneAuthDataV41()
            {
                Header = msg.Header,
                Body   = new KeystoneAuthDataMsg()
                {
                    Application     = application,
                    KS_Applications = ks_applications,
                }
            };

            KeystoneAuthUserMsg    userInfo;
            List <RoleAttribute>   roleAttributeList;
            List <Role>            roleList;
            List <AuthFunctionMsg> functionList;

            AuthFactory.GetInstance().GetAuthData(loginName, domain, out userInfo, out roleAttributeList, out roleList, out functionList);

            result.Body.AuthUser       = userInfo;
            result.Body.RoleAttributes = roleAttributeList;
            result.Body.Roles          = roleList;
            result.Body.Functions      = functionList;
            result.Body.MenuData       = new KeyStoneBiz().GetMenuItems(loginName, domain, languageCode, functionList);

            return(result);
        }
Example #2
0
        public List <UserPVStatisticItem> QueryUserPVStatistic(QueryUserPVStatisticCriteria criteria)
        {
            var da = new StatisticDA();
            List <UserPVStatisticItem> list = da.QueryUserPVStatistic(criteria);

            if (list != null)
            {
                foreach (UserPVStatisticItem item in list)
                {
                    UserInfo u = CPContext.GetUserInfoFromAD(item.UserId, CPContext.GetADDomain());
                    if (u != null && !string.IsNullOrWhiteSpace(u.FullName))
                    {
                        item.UserId = string.Format("{0} - {1} ({2})", u.UserID, u.FullName, u.Department);
                    }
                }
            }
            return(list);
        }
Example #3
0
        public KeystoneAuthDataV41 AutoLogin(DefaultDataContract msg)
        {
            HttpContext context = HttpContext.Current;

            //判断是否是logout后的自动登录,如果是返回数据NULL,并阻止自动登录。
            HttpCookie cookie = context.Request.Cookies[m_key_SignOut];

            if (cookie != null)
            {
                var responseCookie = new HttpCookie(m_key_SignOut);
                responseCookie.Expires = DateTime.Now.AddDays(-30);
                context.Response.Cookies.Add(responseCookie);
                return(new KeystoneAuthDataV41 {
                    Body = null
                });
            }


            if (CPConfig.Application.AutoLogin && !context.Request.IsAuthenticated)
            {
                TryLogin();
            }
            if (context.Request.IsAuthenticated)
            {
                if (HttpContext.Current.Session["IsLoginSystem"] == null)
                {
                    string    loginName = null;
                    string    domain    = null;
                    CPContext cpContext = CPContext.Current;
                    string    userName  = cpContext.GetUserName(out loginName, out domain);
                    TraceLoginEventLog(loginName);
                    HttpContext.Current.Session["IsLoginSystem"] = true;
                }
                KeystoneAuthDataV41 result = new KeystoneAuthDataV41
                {
                    Body = GetAuthData(msg).Body
                };
                return(result);
            }
            return(new KeystoneAuthDataV41 {
                Body = null
            });
        }
Example #4
0
        public KeystoneAuthUserListV41 BatchGetUserInfo(List <string> userIDList)
        {
            KeystoneAuthUserListV41 result = new KeystoneAuthUserListV41();

            result.Body = new List <KeystoneAuthUserMsg>();
            foreach (string userID in userIDList)
            {
                UserInfo user = CPContext.GetUserInfoFromAD(userID, CPContext.GetADDomain());
                result.Body.Add(
                    new KeystoneAuthUserMsg()
                {
                    EmailAddress     = user.EmailAddress,
                    DisplayName      = user.FullName,
                    Domain           = CPContext.GetADDomain(),
                    DepartmentName   = user.Department,
                    DepartmentNumber = user.Department,
                    UserName         = user.UserID,
                });
            }
            return(result);
        }