I know that;

SPWeb.EnsureUser(string loginName);

can be used to add Domain Users with login name, to the site users. But i have a list with only email addresses. How can i add these people to site users?

Is there anyway to get loginName from email address? Or any other way?

1 Answer 1


How about using the following function, Microsoft.SharePoint.Utilities.SPUtility.ResolveWindowsPrincipal()?

It has the following parameters:-

webAppType: Microsoft.SharePoint.Administration.SPWebApplication

inputType: System.String

scopesType: Microsoft.SharePoint.Utilities.SPPrincipalType

inputIsEmailOnlyType: System.Boolean

There are two overloads, suggest you use the SPWebApplication one.

More information at http://msdn.microsoft.com/en-us/library/ee705754.aspx

You can then use the information returned as part of the SPPrincipalInfo object to get the login name to call Ensure User.

  • If that doesn't work. Why dont you just write code to retrieve the domain name from Active Directory using the Email address. Should be pretty simple to do.
    – Fox
    Feb 1, 2013 at 12:44

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.