Tag Info

Hot answers tagged

3

Are you sure that you provided correct code snippet? if it is true, the VS should throw this exception: 'Microsoft.SharePoint.SPPrincipal' is a 'type' but is used like a 'variable' and break build action. You should use principal variable instead of SPPrincipal class: foreach (var principal in listOfPrincipals) { if (principal is SPGroup) { //do stuff } } ...


1

Have you tried running the old STSADM way of migrating users - like the following script. STSADM –o migrateuser –oldlogin MYDOMAIN\old –newlogin MYDOMAIN\new –ignoresidhistory There might be orphaned users which doesn't get handled correct. You can clean up these orphans using the following script: # Clean up accounts that is not imported correctly # ...


1

It looks like there is not simpler solution that this one : public static SPPrincipal GetPrincipal(SPWeb web, int principalID, string principalName) { return web.AllUsers.Cast<SPPrincipal>().SingleOrDefault(u => u.ID == principalID) ?? web.SiteGroups.Cast<SPPrincipal>().SingleOrDefault(g => g.ID == principalID); } Feel free ...


1

I've done this by querying against the web.SiteGroups collection and the web.AllUsers collection, just as you have done, however I didn't cast. I instantiated an SPPrincipal to null and then set it equal to the SPGroup or SPUser before returning it. Here's an example using iteration rather than Linq: private SPPrincipal GetPrincipal(SPSite spsSite, ...



Only top voted, non community-wiki answers of a minimum length are eligible