Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 619443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:39:21+00:00 2026-05-13T18:39:21+00:00

I am currently working on a SharePoint 2010 project where the environment is setup

  • 0

I am currently working on a SharePoint 2010 project where the environment is setup with a SharePoint web application using claims based authentication. The web app is created on port 8081 using Windows Authentication for auth, and extended to port 80 using Forms Based Authentication.

The forms authentication provider is setup to use the same active directory as the windows auth based site, using the following entries in the application’s web.config (the entries are in the central administration and security token service web.config files as well):

    <membership defaultProvider="i">
  <providers>
    <add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    <add name="FBA_AD_MP" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADFBAConnectionString" enableSearchMethods="true" attributeMapUsername="userPrincipalName" />
  </providers>
</membership>

Using this setup works as expected; users who visit the application on port 8081 are presented with a standard windows auth challenge, those on port 80 are directed to the custom login form. When adding users to the site via the out of the box administration tools, a search for a particular user such as john.smith@mydomain.com will return two hits, one from the windows auth provider, one from the forms auth provider. Adding both of these users to a site reveals that SharePoint stores the account name with an identifier appended to the front. The windows auth user is translated to i:0#.w|mydomain\johnsmith, the FBA user is translated to i:0#.f|fba_ad_mp|john.smith@mydomain.com.

Here’s where the problem comes in. We are creating site collections in bulk using a custom built tool that parses a spreadsheet of input, creates site collections, and adds the appropriate users to the newly created site using the following method:

    private static void AddUser(SPSite site, String userName, String spGroupName)
    {
        try
        {
            SPUser spUser = site.RootWeb.EnsureUser(userName);

            if (spUser != null)
            {
                site.RootWeb.Groups[spGroupName].AddUser(spUser);
            }
        }
        catch(Exception ex)
        {
            SharePointManager.Counter.Warnings++;
            SharePointManager.Logger.Warn(String.Format("\t\tUnable to add user {0} to group {1} at site {2}: {3}", userName, spGroupName, site.RootWeb.Url, ex.ToString()));
        }
    }

The userName paramter passed in is, following the example, john.smith@mydomain.com. However, the user added to the site is always the windows auth based user, i:0#.w|mydomain\johnsmith.

How do I specify which authentication provider to poll when calling EnsureUser so I can guarantee that the correct user is added to the site?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:39:22+00:00Added an answer on May 13, 2026 at 6:39 pm

    The problem is that both membership providers recognize the email address, and the first result (AD) gets used. Try FBA_AD_MP:john.smith@mydomain.com – that syntax works in the standard username controls (using check name rather than the search dialog), and I believe EnsureUser works the same way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on an application that displays the data of a Sharepoint
Currently I'm working on this project to create a SharePoint projects portal, but the
I am currently working on a project and my goal is to locate text
I'm currently working on creating a new C# project that needs to interact with
I am currently working on a project with specific requirements. A brief overview of
The system I am currently working on requires some role-based security, which is well
I'm currently working at a small web development company, we mostly do campaign sites
The company I'm currently working for is using Selenium for Uniting-Testing our User Interface.
I'm currently working on an internal sales application for the company I work for,
I'm currently working on an application with a frontend written in Adobe Flex 3.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.