コード例 #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>
        /// 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);
            }
        }