I have 3 security provider for my web application 1. Active Directory 2. ADFS 3. SAML

Now suppose a user exist in all 3 provider.Hence when i do use ensure user method i get error/ exception "user not found". I want that my code should always get the user from active directory and if not found through user not found error.

Can anyone provide me with code snippet.


You can retrieve users as follows:


so suppose your provider is called ContosoMembership and your user is user@web.com, the call would be:


But there's one catch. You have to configure your providers in the context your running your app in. So if this is a console application for instance; make sure the app.config of your console app also holds the proper membership providers! If the providers aren't configured, you will get an error saying the user can't be found. When running in SharePoint context (webpart, application page), it uses the web.config you've configured so you're safe there.

| improve this answer | |

try SPUtility.ResolvePrincipal

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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