I was using SPUtility.ResolvePrincipal to resolve the email address but it only seems to work if the user is already in the User Information List. Is there any way I can resolve users based on email if they do not yet exist in the User Information List?
I have 1,000 emails in the list that need to be resolved to people. There are about 60,000 users in the User Profile Service Application. How would you go about matching them?

Current code follows:

using (SPSite site = new SPSite("http://sp2010/sites/TheSite"))
   if (properties.ListItem["CONTACT EMAIL ADDRESS"] != null)
       string email = properties.ListItem["CONTACT EMAIL ADDRESS"].ToString();
       SPWebApplication webApp = site.WebApplication;
       SPPrincipalInfo pi = null;
       pi = SPUtility.ResolvePrincipal(webApp, null, email, SPPrincipalType.User, SPPrincipalSource.Windows, true);
       if (pi != null)
           UserProfile vmProfile = findUser(pi);
           if (vmProfile != null)

               SPUser user = properties.Web.EnsureUser(pi.LoginName);
               SPFieldUserValue userName = new SPFieldUserValue(properties.Web, user.ID, user.Name);
               properties.ListItem["Vendor Manager"] = userName;

2 Answers 2


If the user is not in the User Information List, how would they have an associated SPUser object with a login etc.?

If ResolvePrincipal() didn't return null here, wouldn't this break when you tried to access a property like you do here: SPUser user = properties.Web.EnsureUser(pi.LoginName);

I think the short answer is no.

  • ResolvePrincipal returns null. I know I could at least compare the list of emails to profiles in the UPSA but that seems like a woefully inefficient way of doing it. Commented Jul 31, 2012 at 14:00
  • Yes, it does return null. By design. Sorry if you didn't catch the double negative in my above statement. If they don't exist in the User Information List, that's your only other option I guess, provided the user exists there and this isn't an external email address. Commented Jul 31, 2012 at 14:05

Careful! EnsureUser, "Checks whether the specified logon name belongs to a valid user of the website, and if the logon name does not already exist, adds it to the website." from MSDN.

But you may use: SPUser user = context.Web.SiteUsers.GetByEmail(fullUserName);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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