locked
People.ResolvePrincipals Method returning -1 inUserInfoID RRS feed

  • Question

  • I'm trying to add a user, programmtically, to a field of Type="User" in a SharepointList. Since I do not know the user's unique ID within the site in advance, I'm using the ResolvePrincipals function to add the user to the SPUserCollection as follows:

     

          Dim managerDN() As String = {"some.user@email.com"}
          Dim principalInfo() As PrincipalInfo = people.ResolvePrincipals(managerDN, SPPrincipalType.User, True)
          Console.WriteLine(principalInfo(0).UserInfoID)
    
    
    Problem is when I look at the UserInfoID, which is what I'm looking for, I get back -1. I assumed that the ResolvePrincipals function would add the user to the site user collection automatically and create a unique, positive, UserInfoID in the process. Why do I get back -1 as the UserInfoID if the function automatically adds the user to the SPUserCollection?

    Tuesday, August 31, 2010 8:29 PM