SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When/why does SPUtility.ResolvePrincipal return a non-null SPPrincipalInfo with a PrincipalId of -1 ? I can manually assign rights to the user through the web interface. The user resides in an active directory. If I request a non existing user null is being returned as expected. The same logic works for a lot of other users.

SPPrincipalInfo principalInfo = SPUtility.ResolvePrincipal(currentWeb, objectPrincipal, SPPrincipalType.All, SPPrincipalSource.All, null, false);
if (principalInfo == null)
  result[i][j] = "Can not determine principalInfo for name: " + objectPrincipal;
if (principalInfo.PrincipalId <= 0)
  result[i][j] = "Got invalid PrincipalId: " + principalInfo.PrincipalId + " in principalInfo for name: " + objectPrincipal;

My log output:

Setting rights failed for user: DOMAIN\usr1 error: Got invalid PrincipalId: -1 in principalInfo for name: DOMAIN\usr1

Any ideas?

share|improve this question
Edit: after manually adding the rights for the user it wont return a PrincipalId of -1 for this user in the future. So it seems like I just need a way to do this "lazy user initialization" via code somehow? – Chris Jan 8 '13 at 16:43
up vote 0 down vote accepted

When null is returned the user does not exist, when PrincipalId -1 is returned I have now used the EnsureUser method to make the existing user known to the sharepoint system.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.