0

I have created a People Picker control for SP Hosted App using CSOM and below API

ClientPeoplePickerWebServiceInterface.ClientPeoplePickerSearchUser

I have to search for user within multiple SharePoint custom group , i know we can narrow our search to a SP group using below property

ClientPeoplePickerQueryParameters querryParams = new ClientPeoplePickerQueryParameters();
querryParams.SharePointGroupID = 13;//where 13 is the ID value for the custom SharePoint group

Now I have to search user within multiple group but SharePointGroupID property takes only one group id. How can i achieve my requirement for search within multiple group.

2

You can ignore SharePointGroupID and include PrincipalSource. In SharePointGroupID, you can provide only one group. Value of PrincipalSource can be

15: Choices are All

4: Membership Provider

8: RoleProvider

1: UserInfoList

2: Windows

These values can be combined

I have a article for building custom people picker.

var data = {
    queryParams: {
        __metadata: {
            type: 'SP.UI.ApplicationPages.ClientPeoplePickerQueryParameters'
        },
        AllowEmailAddresses: true, //This is for the people picker control  
            //and allows valid email addresses to be resolved and used as values
        AllowMultipleEntities: false, //This for the people picker control 
            //and allows for entering multiple users or groups
        AllUrlZones: false, //Only affects the search if you have set the WebApplicationID. 
            //It search across all UrlZones for that particular web application
        MaximumEntitySuggestions: 50, //Basically a row limit of how many users or groups are returned
        PrincipalSource: 15, //What sources you wish to search. Choices are  All - 15 , 
            //Membership Provider - 4 , RoleProvider - 8, 
            //UserInfoList - 1  or Windows - 2. These values can be combined
        PrincipalType: 15, //Controls the type of entities that are returned in the results. 
            //Choices are All - 15, Distribution List - 2 , Security Groups - 4,  
            //SharePoint Groups – 8, User – 1. These values can be combined
        QueryString: "Your search string" //The term to search
        Required: false, //This is for the people picker control and makes the field required. 
            //It has no effect on the search
        SharePointGroupID: null, //An integer representing the group ID you want to limit your search to. 
            //Only works if you set the Web parameter also which cannot be done via REST
        UrlZone: null, // Limits the search to certain zones within the web application. 
            //Can only be used if the UrlZoneSpecified  parameter is set to true. 
            //Choices are Custom - 3, Default - 0, Extranet - 4, Internet – 2, 
            //IntraNet – 1. These values can be combined
        UrlZoneSpecified: false, //Sets whether you are limiting your search 
            //to a particular URL zone in the web application.
        Web: null, //If set it works in conjunction with the SharePointGroupID parameter.
        WebApplicationID: null //String value representing the Guid 
            //of the web application you want to limit your search to
    }
}
  • But i have to pick users from those SharePoint groups not from entire Source as you told. Example : user1 is available Within All source, but user1 is not a member of SP group1 or group 2, so in that case user1 should not come as a suggestion – Jaydeep Shil Oct 13 '15 at 12:28
  • In that case, you will not be able to use this ClientPeoplePicker. Result sources are fixed for this control. You have to look for another end point and another solution. – Atish Dipongkor - MVP Oct 13 '15 at 12:33
  • I need one more input , if i add a AD group to my SP custom group and that AD group having users user1, user2, user3. Now if i search for user1 within that SP custom group my serach result not returning that user info but if i serach for that AD group i am able to get the group , properties has been set like below querryParams.PrincipalSource = PrincipalSource.All; querryParams.PrincipalType = PrincipalType.All; //(PrincipalType)principalType; – Jaydeep Shil Oct 13 '15 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.