









































B.E.(Computer Engg.) Ahmedabad India
A client has just asked me to help them setup a WSS server that will be hosted on the Internet, they do want to create a membership based portal and I suggested that they use the ASP.NET membership system and I would demonstrate a prototype. The second objective was that their internal users logging onto the domain will also need to access the same site using their domain accounts, this can be achieved on SharePoint by using zones. Now I chose a forms based authentication (FBA) mechanism, but you could any other.
In a production environment, I would opt to install both on to a machine even though it will be primarily Internet\Extranet facing, even if it is using the local directory services. This gives a backdoor to managing the site should you have problems with the forms authentication mechanism (or other).
Now I searched the web and found many articles on Forms Authentication for WSS and MOSS, however many of them were incomplete and after several attempts of butchering their solutions, I managed to get it under wraps. I hope this helps you out.
* Note if you do not want to use a domain, you can logon to the local machines directory services.
Now I will discuss a easy but vital key point. First, I am going to create a web application for the public facing site, when the web application is created I will use host headers to indicate the site name, this will leave us with a default zone. Then the internal site will be added by extending the web application, to with a different host header.
Create a web application, at this point I did a standard NTLM site and did not configure anything else.
The basic software and operating systems
Service accounts (GROUNDING is the domain)
You will need to create the following service account in your domain
Now I am not going to walk you through this, you should be able to do this yourself. Neil has a blog post on how to install SharePoint.
In this step I will go through the process of installing the standard ASP.NET SQL Membership database. Now this is going to be the easiest for now, however in the future you could write your own membership and role providers using the .NET framework and some serious C# code. Also, this lab is using the SQL provider, however there are other membership providers available for you to use.
There are various ways to do this, and some pretty easy ones if you have Visual Studio installed. However I am going to do this by running a SQL script. In this step I am going to create the following. Now an important lesson is that the membership database you created can be used by many different applications. Each application can have its own roles, users and members and is uniquely seperated by an "application name".
Important. When using membership you must consistently use the same "application name" when configuring the users, roles, web.config files and any other configuration that membership is involved in. My application will use an application role called SharePoint_Membership.
Users
Roles
Role / User
USE SharePoint_Membership
GO
-- -----------------------------------------
-- Create Roles
EXECUTE [dbo].[aspnet_Roles_CreateRole]
'SharePoint_Membership',
'Administrators'
EXECUTE [dbo].[aspnet_Roles_CreateRole]
'SharePoint_Membership',
'Members'
-- -----------------------------------------
-- Create Users
DECLARE @now datetime
SET @now= GETDATE()
EXECUTE [dbo].[aspnet_Membership_CreateUser]
'SharePoint_Membership'
,'Admin'
,'Pa$$w0rd'
,''
,'admin@grounding.co.za'
,''
,''
,1
,@now
,@now
,0
,0
,null
EXECUTE [dbo].[aspnet_Membership_CreateUser]
'SharePoint_Membership'
,'TestMember1'
,'Pa$$w0rd'
,''
,'testmember1@grounding.co.za'
,''
,''
,1
,@now
,@now
,0
,0
,null
EXECUTE [dbo].[aspnet_Membership_CreateUser]
'SharePoint_Membership'
,'TestMember2'
,'Pa$$w0rd'
,''
,'testmember1@grounding.co.za'
,''
,''
,1
,@now
,@now
,0
,0
,null
-- -----------------------------------------
-- Add Members to Roles
EXECUTE [dbo].[aspnet_UsersInRoles_AddUsersToRoles]
'SharePoint_Membership'
,'Admin'
,'Administrators'
,@now
EXECUTE [dbo].[aspnet_UsersInRoles_AddUsersToRoles]
'SharePoint_Membership'
,'TestMember1'
,'Members'
,@now
EXECUTE [dbo].[aspnet_UsersInRoles_AddUsersToRoles]
'SharePoint_Membership'
,'TestMember2'
,'Members'
,@now
The next step is to ensure that your name resolution works for your internal network as well as your public network. Ensure that you can ping both the servers. Now, if you are just playing around on a virtual machine and not on a "real" network you could cheat by editing the host file in the c:\WINDOWS\system32\drivers\etc\ directory
Important. This is a quick cheat, however you should make sure that DNS is properly configured in your production environment both for internal and external networks.
Now the first step is to provision the public web site in SharePoint, this post is not a tutorial on provisioning, however there are a few important steps to go through
Your web application is provisioned
Now what is the point of a a web application without a site, Provision yourself a site collection.
You should have a site up for the public facing site, albeit using NTLM for authentication. The next step is to create and extend the web application for internal users.
The extended web application will be provisioned.
Both the Central Administration Site, and your Web Application for your site run under different service accounts. You are going to have to logon to SQL server and give them rights in the SharePoint_Membership database. This step is vital and if you do not follow this, you should get an "Unknown Error" when connecting to the site, pretty descriptive.
Basically in SQL add the user GROUNDING\Service_OSS_Db and GROUNDING\Service_OSS_AppPool to the SharePoint_Membership database. Add them to the roles aspnet_Membership_FullAccess and aspnet_Roles_FullAccess roles.
It is important that you make sure all Application pool and service accounts used by SharePoint have access to the membership database, note that if you have SSP, they need access too for security authorisation.
Just to make sure you are on the right track and have not messed up anything, test viewing the site using both internal and external urls
This is now the tricky part, so pay careful attention!!!! or you will have a nightmare resolving any bugs. In this section we will edit the web.config file to enable membership. This is a bit of a butcher on editing the web.config, as you should be provisioning it properly but hey it works. Be careful if you have multiple servers in the farm as this will need to be done on all servers. (Perhaps one day I will write a blog on how to do this properly).
<membership defaultProvider="AspNetMembershipProvider">
<providers>
<remove name="AspNetMembershipProvider" />
<add name="AspNetMembershipProvider"
connectionStringName="AspNetMembershipConnectionString"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="SharePoint_Membership"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
type="System.Web.Security.SqlMembershipProvider,System.Web,Version=2.0.0.0,
Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
providers>
membership>
<roleManager enabled="true" defaultProvider="AspNetRoleProvider">
<providers>
<remove name="AspNetRoleProvider" />
<add name="AspNetRoleProvider"
connectionStringName="AspNetMembershipConnectionString"
applicationName="SharePoint_Membership"
type="System.Web.Security.SqlRoleProvider,System.Web,Version=2.0.0.0,
Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
providers>
roleManager>
Note that the type="......." must be on one line in the file (formatting issue)
<PeoplePickerWildcards>
<clear />
<add key="AspNetMembershipProvider" value="%" />
<add key ="AspNetSqlMembershipProvider" value ="%" />
PeoplePickerWildcards>
You typically would be using the Central Administration site and internal site (portal.grounding.co.za) to manage and configure the site; part of your management will include applying security to users. However these two sites do not know about the membership database, so you are going to have to add the membership settings to their web.config database, but DO NOT change the authentication provider.
This is a bit of a necessary pain, in the central administration and internal site you will be selecting users and applying security using the people picker. If you do not do this, you should get "No exact match was found." errors :
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
Do this for both the Central Admin and Internal site
The easiest way is to restart the web server, however you may wish to Recycle the application pools.
For the purposes of this lab, I will make the membership user admin a Site Collection administrator. If you do not do this and you logon to the public site (currently it does not allow anonymous access), you will get an error that looks like:
This error basically indicates that the user authenticated correctly, however is not authorised to view the page.