예제 #1
0
        /// <summary>
        /// Required if you implement claim resolve in the People Picker.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="entityTypes"></param>
        /// <param name="resolveInput"></param>
        /// <param name="resolved"></param>
        protected override void FillResolve(Uri context, string[] entityTypes, string resolveInput, List <PickerEntity> resolved)
        {
            string        keyword         = resolveInput.ToLower();
            Hashtable     knownClaims     = CRMUserInfo.GetAllClaims();
            List <string> knownClaimsList = new List <string>();

            //Convert the knownClaims.Key into a List<string> for LINQ query.
            foreach (string claim in knownClaims.Keys)
            {
                knownClaimsList.Add(claim);
            }

            var claimQuery = knownClaimsList.Where(claim => claim.IndexOf(keyword) >= 0).Select(claim => claim);

            foreach (string claimValue in claimQuery)
            {
                //Get the ClaimType for the claim type.
                //For example, if you are search "SalesManager", the ClaimType will be CRMClaimType.Role.

                string claimType = CRMUserInfo.GetClaimTypeForRole((string)knownClaims[claimValue]);

                PickerEntity entity = CreatePickerEntity();
                entity.Claim       = CreateClaim(claimType, claimValue, Microsoft.IdentityModel.Claims.ClaimValueTypes.String);
                entity.Description = claimValue;
                entity.DisplayText = claimValue;
                entity.EntityData[PeopleEditorEntityDataKeys.DisplayName] = claimValue;
                entity.EntityType = SPClaimEntityTypes.FormsRole;
                entity.IsResolved = true;
                resolved.Add(entity);
            }
        }
예제 #2
0
        /// <summary>
        /// Implement this method if the claims provider supports claims augmentation.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="entity"></param>
        /// <param name="claims"></param>
        protected override void FillClaimsForEntity(Uri context, SPClaim entity, List <SPClaim> claims)
        {
            if (null == entity)
            {
                throw new ArgumentNullException("entity");
            }
            if (null == claims)
            {
                throw new ArgumentNullException("claims");
            }

            //Add the role claim.
            SPClaim userIdClaim = SPClaimProviderManager.DecodeUserIdentifierClaim(entity);

            //Add claims for users.
            List <string> allCRMUsers = CRMUserInfo.GetAllUsers();

            if (allCRMUsers.Contains(userIdClaim.Value.ToLower()))
            {
                List <Claim> userClaims = CRMUserInfo.GetClaimsForUser(userIdClaim.Value.ToLower());
                foreach (Claim claim in userClaims)
                {
                    claims.Add(CreateClaim(claim.ClaimType, claim.Value, claim.ValueType));
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Resolve a single claim using exact match. This method is required for both claim search
        /// and resolve.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="entityTypes"></param>
        /// <param name="resolveInput"></param>
        /// <param name="resolved"></param>
        protected override void FillResolve(Uri context, string[] entityTypes, SPClaim resolveInput, List <PickerEntity> resolved)
        {
            string    keyword     = resolveInput.Value.ToLower();
            Hashtable knownClaims = CRMUserInfo.GetAllClaims();

            if (knownClaims.ContainsKey(keyword))
            {
                //Get the ClaimType for the claim type.
                //For example, if you are search "SalesManager", the ClaimType will be CRMClaimType.Role.
                //In this case, the keyword is the value of the claim.
                string claimValue = keyword;
                string claimType  = CRMUserInfo.GetClaimTypeForRole((string)knownClaims[keyword]);

                PickerEntity entity = CreatePickerEntity();
                entity.Claim       = CreateClaim(claimType, claimValue, Microsoft.IdentityModel.Claims.ClaimValueTypes.String);
                entity.Description = claimValue;
                entity.DisplayText = claimValue;
                entity.EntityData[PeopleEditorEntityDataKeys.DisplayName] = claimValue;
                entity.EntityType = SPClaimEntityTypes.FormsRole;
                entity.IsResolved = true;
                resolved.Add(entity);
            }
        }