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 method, 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 theResolvePrincipalsmethod of the People web service (_vti_bin/people.asmx) instead.Here is the Microsoft documentation.
The key is to feed in
truefor the value ofaddToUserInfoList. ThePrincipalInfoobject returned by the service call includes aUserInfoID, 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: