An Extended Look at the Profile Object - Part 3
page 4 of 5
by Bilal Haidar
Feedback
Average Rating: 
Views (Total / Last 10 Days): 32601/ 99

Custom Profile Provider

In a previous section, we discussed the Profile provider and stated all of its properties and methods that are implemented and accessed by the Profile object and Profile Manager class.

In developing a custom Profile provider, you will need to implement the same methods and properties according to your data store used and the specific schema you have in your database design.

The default Profile provider that ships with ASP.NET 2.0 inherits from ProfileProvider base class. If we want to create a custom Profile provider we have to inherit from either the ProfileProvider or the AspNetSqlProfileProvider. If we want to have our Profile provider interact with a database different from SQL Server 2000/2005, then the ProfileProvider is the best choice. On the other hand, if the data store used is SQL Server 2000/2005 and what we want is just add some properties or methods to the existing Profile provider, then the latter is the best choice.

The ProfileProvider base class has the following structure shown in Listing 3 below:

 

Listing 3. ProfileProvider Basic Structure

public abstract class ProfileProvider : SettingsProvider

{

  public abstract int DeleteProfiles(ProfileInfoCollection profiles);

  public abstract int DeleteProfiles(string[] usernames);

  public abstract int DeleteInactiveProfiles(

    ProfileAuthenticationOption authenticationOption,
    DateTime userInactiveSinceDate);

  public abstract int GetNumberOfInactiveProfiles(

    ProfileAuthenticationOption authenticationOption,
    DateTime userInactiveSinceDate);

  public abstract ProfileInfoCollection GetAllProfiles(

    ProfileAuthenticationOption authenticationOption, int pageIndex,

    int pageSize, out int totalRecords);

  public abstract ProfileInfoCollection GetAllInactiveProfiles(

    ProfileAuthenticationOption authenticationOption,
    DateTime userInactiveSinceDate, int pageIndex,
    int pageSize, out int totalRecords);

  public abstract ProfileInfoCollection FindProfilesByUserName(

    ProfileAuthenticationOption authenticationOption, string usernameToMatch,

    int pageIndex, int pageSize, out int totalRecords);

  public abstract ProfileInfoCollection FindInactiveProfilesByUserName(

    ProfileAuthenticationOption authenticationOption, string usernameToMatch,

    DateTime userInactiveSinceDate, int pageIndex,
    int pageSize, out int totalRecords);

}

In the above listing, the ProfileProvider seems to inherit from the SettingsProvider. In addition to the methods inherited from the ProfileProvider, the custom Profile provider developer should also implement two other methods inherited from the SettingsProvider, which are the SetPropertyValues and GetPropertyValue. The structure of the SettingsProvider is shown below in Listing 4.

 

Listing 4. SettingsProvider Basic Structure

public abstract class SettingsProvider : ProviderBase

{

  // Properties

  public abstract string ApplicationName { get; set; }

  // Methods

  public abstract SettingsPropertyValueCollection GetPropertyValues(

    SettingsContext context, SettingsPropertyCollection properties);

  public abstract void SetPropertyValues(SettingsContext context,

    SettingsPropertyValueCollection properties);

}

As shown in the listing above, the two methods should be implemented by any custom Profile provider. In addition, if the Web application is scoped to interact with a set of Web applications, then the property called ApplicationName should also be implemented. If you are interested in how to implement such a custom profile, visit this online article: Profile Providers

 

 


View Entire Article

User Comments

Title: Mtbc   
Name: aamir hasan
Date: 2007-02-06 3:36:00 AM
Comment:
if we include master page and then we can not use multiple form why please explain me
Title: Very nspiring info   
Name: Tahir Aziz
Date: 2006-06-20 2:36:00 PM
Comment:
Very weel .. relaly amazing it helps me a lot.. i am a beginer in ASP dvelopment and its reallly use full for me to have very nice and easy tutorials here on this platfprm..:)
thanks a lot.. i hope for new more inspiring tutorials..With all the best keep it up..!!!
Title: An Extended Look at the Profile Object - Part 3   
Name: raja mohamed
Date: 2006-03-17 2:04:47 AM
Comment:
Good
Title: How delete a single property?   
Name: Massimo
Date: 2005-12-27 8:16:05 PM
Comment:
I cannot find how to delete a user properties from the datastore. Do I miss something?






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-10-17 9:25:26 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search