PNP remote provision site user could not be found.

Copper Contributor

We have some stale users on site/list objects that when trying to write to a new location a PNP saved site xml thows an exception for users that don't exist.  "ServerException:  The specified user <username> could not be found".

 

I was going to modify the AddUserToGroup to skip old users via an option in ProvisioningTemplateApplyingInformation or just post process the xml and remove users that I cant find in AD anymore.  Is there any such functionality already in PNP that can eliminate old users from the xml or not save them in the first place?

 

Thank you!  

3 Replies

How do you add the user? and where? do you have a example of the part where you try to add?

I can't say for certain how the user was added originally (not sure if that's what you are asking), I know the users causing the issue were added in the past to sites etc... using the SharePoint 2013 GUI.  The users are no longer with the company so their AD accounts are gone.  Sharepoint still has references to them in site groups, addtional owners/administrators and so the PNP template does it's job and reads these groups/additional owners when extracting a site.  When I try to apply the PNP template to a new site it gets the exception because the user is invalid when the ObjectSiteSecurity code tries to AddUserToGroup.

 

I wrote a utility that parses the PNP template xml and validates each user against AD and removes them. 

It seems it can not find the users so you first have to remove them out the template.