Exemplo n.º 1
0
        public void GetAuthData(string acct, string domain, out KeystoneAuthUserMsg userInfo,
                                out List <RoleAttribute> roleAttributeList, out List <Role> roleList, out List <AuthFunctionMsg> functionList)
        {
            userInfo = this.GetAuthUser(acct, domain);

            List <RoleAttribute> roleAttrs = null;
            Task getRoleAttributesTask     = new Task(() =>
            {
                roleAttrs = this.GetRoleAttributes(acct, domain);
            });

            List <Role> roles        = null;
            Task        getRolesTask = new Task(() =>
            {
                roles = this.GetRoles(acct, domain);
            });

            List <AuthFunctionMsg> funs = null;
            Task getFunctionTask        = new Task(() =>
            {
                funs = this.GetFunctions(acct, domain);
            });

            getRoleAttributesTask.Start();
            getRolesTask.Start();
            getFunctionTask.Start();
            Task.WaitAll(new Task[] { getRoleAttributesTask, getRolesTask, getFunctionTask });

            roleAttributeList = roleAttrs;
            roleList          = roles;
            functionList      = funs;
        }
Exemplo n.º 2
0
        public static AuthUser ToEntity(this KeystoneAuthUserMsg msg)
        {
            AuthUser entity = null;

            if (msg != null)
            {
                entity = new AuthUser()
                {
                    ID               = msg.UserName,
                    LoginName        = msg.UserName,
                    Domain           = msg.Domain,
                    DisplayName      = msg.DisplayName,
                    UserEmailAddress = msg.EmailAddress,
                    DepartmentName   = msg.DepartmentName,
                    DepartmentNumber = msg.DepartmentNumber,
                    UserSysNo        = msg.UserSysNo
                };
            }

            return(entity);
        }
Exemplo n.º 3
0
 public void GetAuthData(string acct, string domain, out KeystoneAuthUserMsg userInfo,
                         out List <RoleAttribute> roleAttributeList, out List <Role> roleList, out List <AuthFunctionMsg> functionList)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
        private KeystoneAuthUserMsg GetAuthUser(string userName, string domain)
        {
            KeystoneAuthUserMsg authUser = new KeystoneAuthUserMsg();

            authUser.CompanyCode = CPConfig.Application.BusinessCode;
            authUser.Domain      = domain;
            authUser.UserName    = userName;
            authUser.CompanyName = "NeweggSoft";

            UserInfo user = CPContext.GetUserInfoFromAD(userName, domain);

            if (!string.IsNullOrWhiteSpace(user.FullName))
            {
                authUser.DisplayName      = user.FullName;
                authUser.EmailAddress     = user.EmailAddress;
                authUser.DepartmentName   = user.Department;
                authUser.DepartmentNumber = user.Department;
            }
            else
            {
                authUser.DisplayName = userName;
            }

            if (CPConfig.ECCentral != null)
            {
                string serviceUrl = CPConfig.ECCentral.ServiceURL;
                if (!string.IsNullOrEmpty(serviceUrl))
                {
                    serviceUrl = serviceUrl.TrimEnd('/');
                    string url = serviceUrl + "/CommonService/User/{0}";

                    url = string.Format(url, userName);
                    WebClient web = new WebClient();
                    web.Encoding = Encoding.UTF8;
                    string resultString = web.DownloadString(new Uri(url));

                    int userSysNo = -1;
                    int.TryParse(resultString, out userSysNo);

                    if (userSysNo != -1)
                    {
                        authUser.UserSysNo = int.Parse(resultString);
                    }
                    else
                    {
                        throw new Exception("Don't found this user system number by current account!");
                    }
                }
                else
                {
                    authUser.UserSysNo = -1;
                }
            }
            else
            {
                authUser.UserSysNo = -1;
            }



            return(authUser);
        }