I need to add a user to a SharePoint-Website (WSS 3.0) via a Web Service.
Using the API I would use the SPWeb.EnsureUser m开发者_开发技巧ethod, but I can't run my own code on the server.
I was hoping the Users and Groups Web Service could help, but it does not provide a suitable method.So, is there a Web Service equivalent to SPWeb.EnsureUser?
I stumbled across this question yesterday. As a matter of fact, there is a Web Service equivalent of web.EnsureUser
, but it is not in the UserGroup Web service. Use the ResolvePrincipals
method of the People web service (_vti_bin/people.asmx) instead.
Here is the Microsoft documentation.
The key is to feed in true
for the value of addToUserInfoList
. The PrincipalInfo
object returned by the service call includes a UserInfoID
, which you can use in other membership-related operations on that site.
Here is an example of using the web service from PowerShell 2.0:
$client = new-webserviceproxy http://mysharepointsite/_vti_bin/people.asmx?wsdl -usedefault
$person = $client.ResolvePrincipals(@('domain\user'), 'User', $true)
# ...
精彩评论