Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to find user-profile using the active directory email account.

Note: its not the 'work-email' but the email in AD.

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

SPUtility.ResolvePrincipal can do this - but I can't guarantee that it'll be fast.

It should be something like:

SPPrincipcalInfo user = SPUtility.ResolvePrincipal( webApp, null, "email", SPPrincipalType.User, SPPrincipalSource.Windows, true);
UserProfileManager profileManager = new UserProfileManager(serviceContext);
if (profileManager.UserExists(user.LoginName))
{
    UserProfile userProfile = profileManager.GetUserProfile(user.LoginName);
}

In this "email" would be your email string. It definitely works, but I have has some issues with speed. It's worth testing.

share|improve this answer
    
I get the following Error:: No Overload for the method ResolvePrincipal takes 5 arguments –  user6194 Dec 29 '11 at 15:06
    
Oops, yes, forgot the second parameter, which can be null - updated example. –  Andy Burns Jan 4 '12 at 16:21
add comment

Your Answer

 
discard

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.