Why no 'ResolvePrincipals' option? Is it because of permissions?

Apr 25, 2012 at 3:59 PM

In trying to create a jquery based autocomplete solution which gives the user a list of user Principals to select from, I found that in order to get the UserInfoID for a user on the given site, that user must be added to some SPUserCollection on that site (http://geek.hubkey.com/2008/01/searching-for-users-or-groups-using.html).  One way to do this is to call the ResolvePrincipals web method and set the 'addToUserInfoList' flag to true.  Doing this server-side, by referencing the People service and calling ResolvePrincipals method, works just as it should.

I notice that there is no ResolvePrincipals operation for SPServices, so I decided to add my own.  However, calling this method gives a permissions error when I set 'addToUserInfoList' flag to true; setting it to false doesn't give an error but of course doesn't actually add the user. 

So, my question is, is this by design?  Is there something special about 'ResolvePrincipals' that makes it unsuitable to implement using jQuery?  Does it have something to do with permissions? 

Here are my artifacts:

code to implement 'ResolvePrincipals' web method (operation):

//added

WSops.ResolvePrincipals = [PEOPLE, false];

...

case "ResolvePrincipals":
     addToPayload(opt, ["principalKeys", "principalType", "addToUserInfoList"]);
     break;

code to execute 'ResolvePrincipals' client-side:

 

$().SPServices({
	operation: "ResolvePrincipals",
	principalKeys: "<string>" + ui.item.__ParameterForLookup + "</string>",
	addToUserInfoList: true,
	principalType: "User",
	async: false,
	completefunc: function(xData, Status){
		DebugWrite("ResolvePrincipals", xData);

	}
});

 

xml payload sent to People web service:

 

<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
	<soap:Body>
		<ResolvePrincipals xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
			<principalKeys>
				<string>domain/username</string>
			</principalKeys>
			<principalType>User</principalType>
			<addToUserInfoList>true</addToUserInfoList>
		</ResolvePrincipals>
	</soap:Body>
</soap:Envelope>

 

response as read from xData (http status 500):

 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<soap:Fault>
			<faultcode>soap:Server</faultcode>
			<faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring>
			<detail>
				<errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.</errorstring>
				<errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x8102006d</errorcode>
			</detail>
		</soap:Fault>
	</soap:Body>
</soap:Envelope>

 

 

Coordinator
Apr 25, 2012 at 6:31 PM

Jeff:

The only reason it's not there is that I never added it. It also wasn't available in 2007.
http://msdn.microsoft.com/en-us/library/websvcpeople.people.resolveprincipals.aspx

I'm guessing that you are indeed seeing a permissions issue. Since I've never tried the operation, I don't know exactly what it needs.

Thanks for the code bits above. I'll add the operation into the next release.

M.

Coordinator
Apr 25, 2012 at 6:32 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Apr 25, 2012 at 6:38 PM

p.s. The errors we get from the Web Services are often quite misleading. It may well mean something entirely different than what it says.

M.

Coordinator
May 31, 2012 at 12:20 PM

FYI - I've added the ResolvePrincipals operation into the latest alpha. Check the work item link above for details. Let me know if you get a chance to try it out!

M.