protected override bool CheckAccessCore(OperationContext operationContext)
        {
            IPrincipal principal = operationContext.ServiceSecurityContext.AuthorizationContext.Properties["Principal"] as IPrincipal;

            if (principal != null)
            {
                CustomPrincipal cp = principal as CustomPrincipal;

                if (cp != null && (cp.IsInRole(Permissions.Read.ToString()) || cp.IsInRole(Permissions.Generate.ToString()) || cp.IsInRole(Permissions.Delete.ToString()) || cp.IsInRole(Permissions.DeleteAll.ToString())))

                {
                    return(true);
                }
            }

            return(false);
        }
        public virtual IPrincipal GetPrincipal(IIdentity identity)
        {
            lock (locker)
            {
                IPrincipal      principal   = null;
                WindowsIdentity winIdentity = identity as WindowsIdentity;

                //string idenName = identity.Name;
                //string[] idenNameSplit = idenName.Split(',');
                //string[] cn = idenNameSplit[0].Split('=');
                //string username = cn[1];
                //string[] ou = idenNameSplit[1].Split('=');
                //string group = ou[1];

                if (identity != null)//ovde je bilo !=winIdentity
                {
                    principal = new CustomPrincipal(winIdentity);
                }
                return(principal);
            }
        }
示例#3
0
        public string Login(string LoginName, string Password, string ValidateCode)
        {
            bool   result = false;
            string msg    = string.Empty;

            if (string.IsNullOrEmpty(Password))
            {
                msg = General.Resource.Common.Password + General.Resource.Common.Required;
            }
            else if (!Session["ValidateCode"].Equals(ValidateCode))
            {
                msg = General.Resource.Common.VerifyCodeWrong;
            }
            else
            {
                List <FMS.Model.T_User> users = new UserService().GetUsers(LoginName, Password);
                if (users.Count.Equals(0))
                {
                    msg = General.Resource.Common.AccOrPwdWrong;
                }
                else
                {
                    Session["MasterCompanyGuid"] = users.First().C_GUID;
                    UserData dat = GenerateUserData(users.First().LoginName);
                    base.userData = dat;
                    CustomPrincipal.SignIn(dat);
                    CustomPrincipal.TrySetUserInfo(this.HttpContext.ApplicationInstance.Context);
                    if (Session["LogicGUID"] == null)
                    {
                        Session["LogicGUID"] = Guid.NewGuid().ToString();
                    }
                    result = true;
                }
            }
            return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}",
                                 result.ToString().ToLower(), msg));
        }