My SharePoint World! - Nishant Shah

How-Tos, Thoughts and Experiences with Microsoft SharePoint !

How to configure Forms Based Authentication – Active Directory (LdapMembership)

How to configure Forms Based Authentication – Active Directory (LdapMembership)

  • Comments 36
  • Likes

 

Enable Forms Based Authentication

This process can be broadly divided into 3 sections:

 

  • Extend the SharePoint Web Application (or create a new SharePoint Web Application)
  • Make entries in the web.config
  • Configure forms authentication in central administration

 

Extend the SharePoint Web Application

We have a SharePoint site present on port 80 which uses NTLM authentication. For our purposes, we will extend the SharePoint Web Application to port 8080 in which we will configure Forms Authentication

(Note: Make sure the port you choose to extend is not already used)

 

  • Go to Central Administration > Application Management > Create or Extend Web Application > Extend an existing Web application
  • Select a Web Application by clicking on No Section and choosing Appropriate Web Application
  • Type in the correct Port i.e. 8080 in our case
  • Make sure "Allow Anonymous" is set to Yes (so that users can browse at least to Forms Login Page)
  • Make a note of Zone being used (Choose Intranet if available) and verify Load Balanced URL looks okay (i.e. http://servername:8080 in our case) and click OK

 

Make Entries in the Web.Config

As a first step to enable forms authentication, you need to make entries in the web.config file of the "SharePoint Central Administration Web application" and of the "SharePoint Web application" you wish to use Forms Authentication (it can be a new SharePoint Web Application or an Extended Web Application).

 

Have the information on following points handy according to your environment -

 

server="DC.Contoso.com"

DC is the server running Active Directory. DC will service all LDAP requests for the SSP (This needs to be changed to reflect one of your Domain Controller which you want SharePoint to use)

port="389"

The default port number used by LDAP is 389. (Generally this doesn’t need to be changed unless you’re using a custom LDAP port)

userContainer=“OU=OrgUsers,DC=contoso,DC=com

User objects in Active Directory are located inside the OrgUsers OU in the contoso.com domain (This needs to be changed according to where your users – who needs to access SharePoint thru Forms Auth. are stored)

groupContainer="OU=OrgGroups,DC=contoso,DC=com"

Groups in Active Directory are located inside the OrgGroups OU in the contoso.com domain (This needs to be changed according to where your Groups are stored)

 

Complete the following steps on the SharePoint server(s) (all Web Front End Servers).

I personally recommend copying the following excerpts in MS Word, updating the appropriate sections (in Red) and pasting them in the web.config file in appropriate section.

 

  • Locate the web.config file used by the SharePoint Central Administration website
  • Take backup of web.config file by saving it with different name
  • Open the web.config file of the Central Administration Web site in Notepad
  • Paste the copied text under the <system.web> root section in the web.config file. The text you paste should look like the excerpt below. The parameters highlighted in red below are the ones which should be changed according to prepared in Table above:

 

<membership defaultProvider="LdapMembership">

<providers>

<add name="LdapMembership"

 type="Microsoft.Office.Server.Security.LDAPMembershipProvider, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"

 server="DC.Contoso.com"

 port="389"

 useSSL="false"

 userDNAttribute="distinguishedName"

 userNameAttribute="sAMAccountName"

 userContainer="OU=OrgUsers,DC=contoso,DC=com"

 userObjectClass="person"

 userFilter="(|(ObjectCategory=group)(ObjectClass=person))"

 scope="Subtree"

 otherRequiredUserAttributes="sn,givenname,cn" />

</providers>

</membership>

<roleManager defaultProvider="AspNetWindowsTokenRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".PeopleDCRole">

<providers>

<add name="LdapRole"

 type="Microsoft.Office.Server.Security.LDAPRoleProvider, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"

 server="DC.Contoso.com"

 port="389"

 useSSL="false"

 groupContainer="OU=OrgGroups,DC=contoso,DC=com"

 groupNameAttribute="cn"

 groupMemberAttribute="member"

 userNameAttribute="sAMAccountName"

 dnAttribute="distinguishedName"

 groupFilter="(ObjectClass=group)"

 scope="Subtree" 

/>                                         

</providers>

</roleManager>

 

  • Save the web.config file and exit Notepad 
  • Now, locate the web.config file used by the extended SharePoint Web Application website (i.e. site on port 8080 in our case)
  • Take backup of web.config file by saving it with different name
  • Paste the copied text under the <system.web> root section in the web.config file. The text you paste should look like the excerpt below. The parameters highlighted in red below are the ones which should be changed according to prepared in Table above:

 

<membership defaultProvider="LdapMembership">

<providers>

<add name="LdapMembership"

 type="Microsoft.Office.Server.Security.LDAPMembershipProvider, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"

 server="DC.Contoso.com"

 port="389"

 useSSL="false"

 userDNAttribute="distinguishedName"

 userNameAttribute="sAMAccountName"

 userContainer="OU=OrgUsers,DC=contoso,DC=com"

 userObjectClass="person"

 userFilter="(|(ObjectCategory=group)(ObjectClass=person))"

 scope="Subtree"

 otherRequiredUserAttributes="sn,givenname,cn"

/>

</providers>

</membership>

<roleManager defaultProvider="LdapRole" enabled="true" cacheRolesInCookie="true" cookieName=".PeopleDCRole">

<providers>

<add name="LdapRole"

 type="Microsoft.Office.Server.Security.LDAPRoleProvider, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"

 server="DC.Contoso.com"

 port="389"

 useSSL="false"

 groupContainer="OU=OrgGroups,DC=contoso,DC=com"

 groupNameAttribute="cn"

 groupMemberAttribute="member"

 userNameAttribute="sAMAccountName"

 dnAttribute="distinguishedName"

 groupFilter="(ObjectClass=group)"

 scope="Subtree" />

</providers>

</roleManager>

 

  • Save the web.config file and exit Notepad
  • Open a command prompt window and run IISRESET (do IISRESET all other Web Front Ends if there are more than one web servers) 

 

 

Configure Forms-Based Authentication in Central Administration

  • Go to Central Administration > Application Management > Authentication Providers
  • Ensure you select SharePoint in the Web Application drop down
  • Click on the zone which you noted down earlier (should be Intranet by default)
  • Choose Forms under Authentication Type section and also make sure "Enable anonymous access" is checked
  • Type LdapMembership in the Membership Provider Name section
  • Type in the name of the LDAP role provider as LdapRole in the Role Manager Name text box 
  • If you are at WSS & MOSS SP2 or greater then you check "Enable Client Integration" else leave it unchecked
  • Click Save

 

Note: At this point SharePoint automatically enables anonymous access on the Web application for which you enabled forms authentication however there are no users who can access the Forms Authentication site (as DOMAIN\SPSAdmin is NOT equal to LdapMembership:SPSAdmin), so we need to grant at least 1 user Full Control permissions who can log in and grant permissions to other users as needed

 

  • Go to Central Administration > Application Management > Policy for Web application
  • Click Add Users in the tool bar. The Add Users page is displayed for you
  • Ensure you have correct (extended 8080 in our case) SharePoint Web application selected in the Web Application section.
  • Select the appropriate zone (noted earlier) in the Select the Zone section (Intranet in our case) and click Next
  • You can add the user by simply typing LdapMembership:Username or click the book icon Select People and Groups dialog and search for a user there

 

Note:

  • Do not type in username in DOMAIN\UserName format as we are using LdapMembership:UserName format here
  • Only the Users from userContainer="OU=OrgUsers,DC=contoso,DC=com" (which we used in web.config) will be searched / can be added

 

  • Select "Full Control –  Has full control" check box in the Choose Permissions section and click Finish, you should see the User is now added in Policy for Web Application with Full Control
  • Go to Central Administration > Application Management > Site collection administrators > Choose the appropriate site collection in appropriate web application
  • Type in LdapMembership:Username (same account which we added earlier to Policy for Web Application) in Secondary Site Collection Administrator and click OK
  • Browse to the SharePoint Web Application which we extended (site in port 8080 in our case)
  • Log in using the username which we used in Policy for Web Application and add users whoever needs access to SharePoint site thru FBA (as DOMAIN\SPSAdmin is NOT equal to LdapMembership:SPSAdmin that means if you've added some users in the same SharePoint site using NTLM authentication, they will NOT have access in Forms Auth site unless you add them)
  • We're done! Please take time to provide comments / feedback !!!
  • Thank you so much for your code.  I have searched wide and far and apparently this your documentation/code were clear and precise and well, it works!

  • You mentioned the centradmin default website also to be modified to Forms authentication I did not see any provision for that .

    I changed the central admin web config also the application web config to point it to the right LDAP

    But one thing I did not get is what is this spsadmin account you mentioned in the end ?

    I was not able to get  the login screeen after I changed the central admin web config alone and the application web config change and authentication to Forms

    Please advise if you can

  • Hi Satish,

    You need to modify both Central Admin web.config and Web Application web.config in order to configure forms authentication.

    Users in Windows Authentication and users in Forms Authentication are considered different and unique, so for the first time when you configure Forms Authentication, none of the users have access to login to the SharePoint site using Forms Authentication and thats why you need to add at-least 1 user thru Policy for Web App (or change one of the site collection Admin) and then login with that user and manage permissions for other users...

    I recommend following the blog step-by-step and you should be able to get it right. Making correct changes in the web.config is the key to Forms Auth.

    You can read more at -

    http://technet.microsoft.com/en-us/library/cc288043.aspx

    Also, if you need to implement different type of Forms Auth then this one, samples available at

    http://technet.microsoft.com/en-us/library/cc288259.aspx

    HTH.

    Regards,

    Nishant

  • Hi Nishant,

    I have made the required changes to both the web.config files in central administration site and application site. I am able to see the forms authentication form as well but when I go to Policy for Web Application -> Add Users, I get the form to add users but I am not able to find any of the users in my domain. Not sure if you have seen this before or if I am missing out something.

    Would really appreciate your help on this.

    thanks

  • Hi Simran,

    I think you're missing out on correct configuration entries in web.config files. Have you added the above entries (after making relevent changes according to your domain and OU) to both Central Admin & Web Application's web.config?

    Regards,

    Nishant

  • I have configured FBA properly and it works. In the 10th Step(policy for web application) of your article, instead of having One user(admin) i have bunch of users who are administrators. I have created a security group in AD and it holds all the users. When i add that particular AD group in the 10th step that you mentioned, i am getting "access denied" error. What do you think might be the problem. Instead of AD Group, if i add AD User it works fine. Any help would be greatly appreciated. My email id is sravankasyapk@gmail.com

  • I was wondering how I can correctly a configure a web configuration file so that all applications are accepted within Microsoft IIS7?

  • Hi Nishant,

    I've done all the steps without any issue but still i am not able to login in the FBA enabled site.

    Any idea ?

    Thanks,

    Sohaib

  • Got this working with (attributeMapUsername="sAMAccountName" ) for both central admin & internet site. However I got the same issue as sravan has. The site lets you login, when we add individual AD users in the policy for web application. Does not work for AD groups. Should be a setting in the membership provider

  • Hi Nishant,

    I read your article and made all the changes. I have the LDAp path that looks like this..

    LDAP://infinmumcfac.inf.com OU=Infotech,DC=inf,DC=com

    I am also able to see the forms authentication form as well but when I go to Policy for Web Application -> Add Users, I get the form to add users but I am not able to find any of the users in my domain

    I could not fit this into the sample entry provided by you. Could you please modify your text as per these entries and reply me. Please.

    Thanks..Nutan

  • @Sravan: I just changed most of the steps today to make it even more clear, you should add only a user in Authentication Providers and add the other users / groups after logging in with the user which you added in Auth Providers. HTH.

    @ Adrian: Not sure if I understand your question correctly but the steps are similar for IIS 7 as well although IIS 7 interface is different, however we are not making any IIS site level changes so that shouldnt matter, if this doesnt answer your question, please re-post the question with more clarity.

  • @Sohaib: I just changed most of the steps today to make it even more clear. Pls go thru the blog again and let me know if you are able to 1) Find the Ldap user in CA 2) Login to FBA site

    @Onions: Answered Sravan's query above, pls refer.

    @Nutan: By the looks of string you provided, I think you're trying to configure ADMembership Provider (generally used for WSS) however this blog talks about LdapMembership Provider (which is a better option if you have MOSS as ADMembership cannot make use of LdapRole).

  • Nishant, Can you tell me how this can be applied to the situation where the membership provider needs to see AD built in service accounts (farm account for CA) as well as a specific security group and the AD Users object?  I can't seem to get this to see all of those at the same time in order to specify the primary and secondary site collection admins.  Note I did not extend an existing application as you specified.  My goal is to simply eliminate the Windows security dialog for our users.  -- Thanks!

  • @ mcpsspa: You would need to have the User accounts under a single OU which needs to use LdapMembershipProvider. Our scenario here is limited to have one OU for users and one OU for Groups. Its fine even if you dont extend the application and just want to make use of LdapMembership entirely to avoid Windows Authentication.

  • Nishant, great guide. I am having an issue with the FBA site. I can add a user with Full Control and as a Site Collection Admin, and they resolve as ldapmembership:username, but when I go to log in, I just keep getting the login page. I don't even get an Access Denied page. Any thoughts?

    Thanks!

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment