Académique Documents
Professionnel Documents
Culture Documents
I assume your web application is created and configured correctly and the SSP admin
application also. At first we need to enable Asp.net form authentication (FBA) at your
web application.
1. Open your web application directory and find the web.config file and replace the
LocalSqlServer connection string as the following: “<add name="LocalSqlServer"
connectionString="Server=.;Database=aspnetdb;uid=<you user id>;pwd=<your password>;"
providerName="System.Data.SqlClient" />”
2. Create user for admin and roles for registered users by using the tool provided in
visual studio 2008 “ASP.NET Configuration”
3. To enable Roles in web.config you can use the previous tool or add the
following line in web.config right after “<system.web>” tag “<roleManager
enabled="true" cacheRolesInCookie="false" />”.
4. Go to Central Administration > Application Management > Application
Security > Authentication Providers.
5. Choose your web application from the dropdown list then click on the zone. Set
authentication type to “Forms” and set membership provider name to
“AspNetSqlMemebershipProvider” and role manager name to “AspNetS
qlRoleProvider” and ensure that the enable client is set to “NO” then click save.
Before trying the code of editing profile we have to set permission for users to
edit their profile. We must let the SSP Admin application to be aware of the users
and roles in aspnetdb (which is our custom provider). This can be achieved by
extending the web application which has the SSP Admin application by the
following steps:
The code below for sample page with sample fields (properties). Notice that the
previous steps are made to enable security for “CreateUserProfile()” function.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.Office.Server;
namespace Registration.ApplicationPages
try
if(!this.Page.IsPostBack){
ServerContext context =
ServerContext.GetContext(site);
web.AllowUnsafeUpdates = true;
UserProfile up;
if (!profileManager.UserExists(accountName))
up =
profileManager.CreateUserProfile(accountName);
else
up = profileManager.GetUserProfile(accountName);
LoadProperties(up);
//foreach( Property p in profileManager.Properties){
// Response.Write(p.Name+"<br>");
//}
catch (Exception d)
txtFirstName.Text = (string)up["FirstName"].Value;
txtFirstNameAr.Text = (string)up["FirstNameAr"].Value;
txtMiddleName.Text = (string)up["MiddleName"].Value;
txtMiddleNameAr.Text = (string)up["MiddleNameAr"].Value;
txtLastName.Text = (string)up["LastName"].Value;
txtLastNameAr.Text = (string)up["LastNameAr"].Value;
try
{
using (SPSite site = SPContext.Current.Site)
web.AllowUnsafeUpdates = true;
UserProfile up;
if (profileManager.UserExists(accountName))
up = profileManager.GetUserProfile(accountName);
up["FirstName"].Value = txtFirstName.Text;
up["FirstNameAr"].Value = txtFirstNameAr.Text;
up["MiddleName"].Value = txtMiddleName.Text;
up["MiddleNameAr"].Value = txtMiddleNameAr.Text;
up["LastName"].Value = txtLastName.Text;
up["LastNameAr"].Value = txtLastNameAr.Text;
up.Commit();
LoadProperties(up);
else
catch (Exception d)
Best regards,
Abdulhamid