OracleProfileProvider Class

OracleProfileProvider enables ASP.NET developers to easily store Web site user profile information in an Oracle database.

Class Inheritance

System.Object

  System.Configuration.Provider.ProviderBase

    System.Configuration.SettingsProvider

      System.Web.Profile.ProfileProvider

       Oracle.Web.Profile.OracleProfileProvider

Declaration

// C#
public class OracleProfileProvider: ProfileProvider

Thread Safety

All public static methods are thread-safe, although instance members are not guaranteed to be thread-safe.

Remarks

This class allows ASP.NET applications to store and manage profile information in an Oracle database.

Example

The following is a web.config file example for an ASP.NET application that uses OracleProfileProvider as the default provider. This configuration uses the connection string and default attribute values specified in the machine.config file. Profile properties are specified in the properties section. This example also enables anonymous identification and allows anonymous users to set properties.

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.web>
    <anonymousIdentification enabled="true"/>
    <profile enabled="true" defaultProvider="OracleProfileProvider">
      <!-- Profile properties -->
      <properties>
        <add name="hire_date" allowAnonymous="true" type="DateTime"/>
        <add name="location" allowAnonymous="true" 
                            defaultValue="Redwood Shores"/>
        <add name="experience" allowAnonymous="true" type="int"/>
      </properties>
    </profile>
  </system.web>
</configuration>

The following is a web.config file example for an ASP.NET application that uses an OracleProfileProvider with customized settings and an application-specific connection string. Profile properties are specified in the properties section. This example also enables anonymous identification and allows anonymous users to set properties.

<?xml version="1.0"?>
<configuration xmlns=
  "http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
    <add name="my_profile_app_con_string" connectionString=
       "User Id=scott;Password=tiger;Data Source=Oracle"/>
  </connectionStrings>
  <system.web>
    <!-- Enable and customize OracleProfileProvider settings -->
    <anonymousIdentification enabled="true"/>
    <profile enabled="true" defaultProvider="MyOracleProfileProvider">
      <providers>
        <add name="MyOracleProfileProvider"
             type="Oracle.Web.Profile.OracleProfileProvider, 
             Oracle.Web, Version=2.112.2.0, Culture=neutral, 
             PublicKeyToken=89b483f429c47342" 
             connectionStringName="my_profile_app_con_string"
             applicationName="my_profile_app"/>
      </providers>
      <!-- Profile properties -->
      <properties>
        <add name="hire_date" allowAnonymous="true" type="DateTime"/>
        <add name="location" allowAnonymous="true" 
                  defaultValue="Redwood Shores"/>
        <add name="experience" allowAnonymous="true" type="int"/>
      </properties>
    </profile>
  </system.web>
</configuration>

Note that the applicationName attribute should be set to a unique value for each ASP.NET application.

Requirements

Namespace: Oracle.Web.Profile

Assembly: Oracle.Web.dll

Oracle Providers for ASP.NET Version: Oracle Providers for ASP.NET 2.0 and Oracle Providers for ASP.NET 4


OracleProfileProvider Members

OracleProfileProvider members are listed in the following tables.

OracleProfileProvider Constructors

The OracleProfileProvider constructor is listed in Table 6-1.

Table 6-1 OracleProfileProvider Constructor

Constructor Description

OracleProfileProvider Constructors

Instantiates a new instance of the OracleProfileProvider class


OracleProfileProvider Static Methods

OracleProfileProvider static methods are listed in Table 6-2.

Table 6-2 OracleProfileProvider Static Methods

Static Methods Description

Equals

Inherited from System.Object (Overloaded)

ReferenceEquals

Inherited from System.Object


OracleProfileProvider Public Properties

OracleProfileProvider public properties are listed in Table 6-3.

Table 6-3 OracleProfileProvider Public Properties

Public Properties Description

ApplicationName

Gets or sets the name of the application that groups the profile information

CommandTimeout

Gets the number of seconds that the command is allowed to execute before it is terminated with an exception

Description

Inherited from System.Configuration.Provider.Providerbase

Name

Inherited from System.Configuration.Provider.Providerbase


OracleProfileProvider Public Methods

OracleProfileProvider public methods are listed in Table 6-4.

Table 6-4 OracleProfileProvider Public Methods

Public Methods Description

DeleteInactiveProfiles

Deletes user profile data that has its last activity date on or before the specified date and time

DeleteProfiles

Deletes profile properties and information from the data source for the supplied profile collection or list of user names (Overloaded)

Equals

Inherited from System.Object (Overloaded)

FindInactiveProfilesByUserName

Retrieves inactive profile information for the specified user name

FindProfilesByUserName

Retrieves profile information for the specified user name

GetAllInactiveProfiles

Retrieves all profile information for profiles with the last activity date on or before the specified date and time

GetAllProfiles

Retrieves all profile information from the data source

GetHashCode

Inherited from System.Object

GetNumberOfInactiveProfiles

Returns the count of profiles where the last activity date is on or before the specified date and time

GetPropertyValues

Retrieves profile properties and values from the Oracle profile database

GetType

Inherited from System.Object

Initialize

Initializes the OracleProfileProvider instance with the property values specified in the ASP.NET application configuration file (web.config)

SetPropertyValues

Updates the Oracle profile database with the specified profile property values

ToString

Inherited from System.Object



OracleProfileProvider Constructors

This constructor instantiates a new instance of the OracleProfileProvider class.

Overload List:

OracleProfileProvider()

This constructor instantiates a new instance of the OracleProfileProvider class.

Declaration

// C#
public OracleProfileProvider();

Remarks

This constructor is called by ASP.NET to create an instance of the OracleProfileProvider class as specified in the configuration file for the application. Initialization values for an OracleProfileProvider instance are passed through the Initialize method.

This constructor is not intended to be used directly by the application.


OracleProfileProvider Static Methods

OracleProfileProvider static methods are listed in Table 6-5.

Table 6-5 OracleProfileProvider Static Methods

Static Methods Description

Equals

Inherited from System.Object (Overloaded)

ReferenceEquals

Inherited from System.Object



OracleProfileProvider Public Properties

OracleProfileProvider public properties are listed in Table 6-6.

Table 6-6 OracleProfileProvider Public Properties

Public Properties Description

ApplicationName

Gets or sets the name of the application that groups the profile information

CommandTimeout

Gets the number of seconds that the command is allowed to execute before it is terminated with an exception

Description

Inherited from System.Configuration.Provider.Providerbase

Name

Inherited from System.Configuration.Provider.Providerbase


ApplicationName

This property gets or sets the name of the application that groups the profile information.

Declaration

// C#
public override string ApplicationName{get; set;}

Property Value

The name of the application. If the applicationName attribute is not specified in the application configuration file, or if the value is an empty string, then this property is set to the application virtual path.

Exceptions

HttpException - The ApplicationName property was set by a caller that does not have high ASP.NET hosting permission.

System.Configuration.Provider.ProviderException - The application name supplied exceeds 256 characters.

ArgumentException - The application name supplied is an empty string or a null reference.

Remarks

The string value of the ApplicationName property is used for organizing user information.

Multiple ASP.NET applications can use the same data source and create duplicate user names because user information is stored uniquely for each application name. This property can be set programmatically, or it can be set declaratively in the configuration file for the Web application using the applicationName attribute. The attribute name in the configuration file is case-sensitive.

The ApplicationName property is not thread-safe. It is recommended that application code not allow users to set the ApplicationName property in Web applications.

CommandTimeout

This property gets the number of seconds that the command is allowed to execute before it is terminated with an exception.

Declaration

// C#
public int CommandTimeout {get;}
 

Property Value

An int.

Remarks

To customize a provider, ASP.NET developers can set an integer value for this property through the web.config file using the commandTimeout attribute.

The default value is 30 seconds. The attribute name in the configuration file is case-sensitive.


OracleProfileProvider Public Methods

OracleProfileProvider public methods are listed in Table 6-7.

Table 6-7 OracleProfileProvider Public Methods

Public Methods Description

DeleteInactiveProfiles

Deletes user profile data that has its last activity date on or before the specified date and time

DeleteProfiles

Deletes profile properties and information from the data source for the supplied profile collection or list of user names (Overloaded)

Equals

Inherited from System.Object (Overloaded)

FindInactiveProfilesByUserName

Retrieves inactive profile information for the specified user name

FindProfilesByUserName

Retrieves profile information for the specified user name

GetAllInactiveProfiles

Retrieves all profile information for profiles with the last activity date on or before the specified date and time

GetAllProfiles

Retrieves all profile information from the data source

GetHashCode

Inherited from System.Object

GetNumberOfInactiveProfiles

Returns the count of profiles where the last activity date is on or before the specified date and time

GetPropertyValues

Retrieves profile properties and values from the Oracle profile database

GetType

Inherited from System.Object

Initialize

Initializes the OracleProfileProvider instance with the property values specified in the ASP.NET application configuration file (web.config)

SetPropertyValues

Updates the Oracle profile database with the specified profile property values

ToString

Inherited from System.Object


DeleteInactiveProfiles

This method deletes user profile data that has its last activity date on or before the specified date and time.

Declaration

// C#
public override int DeleteInactiveProfiles(ProfileAuthenticationOption 
   profileAuthenticationOption, DateTime inactiveSinceDateTime);

Parameters

  • profileAuthenticationOption

    The options are Anonymous, Authenticated, or All, to indicate which profiles to delete.

  • inactiveSinceDateTime

    The cut-off date and time that indicate a profile is inactive.

Return Value

An integer value that indicates the number of inactive profiles deleted from the data source.

Remarks

This method deletes inactive profile data from the data source for the application specified by the applicationName attribute in the configuration file. The profileAuthenticationOption parameter specifies whether to search only anonymous profiles, only authenticated profiles, or all profiles. This method deletes any profile with a last activity date and time occurring on or before the specified inactiveSinceDateTime parameter value.

The delete profiles operation is a transactional operation. If an error is encountered, the transaction is rolled back and no changes are made.

DeleteProfiles

This method deletes profile properties and information from the data source for the supplied profile collection or list of user names.

Overload List

DeleteProfiles(ProfileInfoCollection)

This method deletes profile properties and information from the data source for the supplied profile collection.

Declaration

// C#
public override int DeleteProfiles(ProfileInfoCollection profileInfoCollection);

Parameters

  • profileInfoCollection

    A ProfileInfoCollection object that contains profile information for profiles to be deleted.

Return Value

An integer value indicating the number of profiles that were deleted from the data source.

Exceptions

ArgumentException - One of the following conditions exists:

  • The value of Count in the profileInfoCollection parameter is 0.

  • One of the ProfileInfo objects in the profileInfoCollection collection has an invalid UserName property, such as an empty string, exceeds 256 characters, or contains a comma.

ArgumentNullException - One of the following conditions exists:

  • The profileInfoCollection parameter is a null reference.

  • One of the ProfileInfo objects in profileInfoCollection collection has a UserName property that is a null reference.

Remarks

This method deletes all profile properties and information for the supplied profile collection from the data source for the application specified by the applicationName attribute in the configuration file. A ProfileInfoCollection object can be obtained from the GetAllProfiles, GetAllInactiveProfiles, FindProfilesByUserName, and FindInactiveProfilesByUserName methods.

The value returned may be different from the Count value of the supplied collection, because some of the profiles in the supplied collection are no longer found in the data source.

The delete profiles operation is a transactional operation. If an error is encountered, the transaction is rolled back and no changes are made.

DeleteProfiles(string[])

This method deletes profile properties and information from the data source for the supplied list of user names.

Declaration

// C#
public override int DeleteProfiles(string[] userNames);

Parameters

  • userNames

    A string array of user names whose profiles are to be deleted.

Return Value

An integer value indicating the number of profiles that were deleted from the data source.

Exceptions

ArgumentNullException - The userNames parameter is a null reference or one of the items in userNames array has a null reference.

ArgumentException - One of the following conditions exists:

  • The length of the userNames array is 0.

  • One of the items in the userNames array has an invalid user name, such as an empty string, exceeds 256 characters, or contains a comma.

  • There are duplicated user names in the userNames array.

Remarks

This method deletes all profile properties and information from the data source for the supplied list of user names for the application specified by the applicationName attribute in the configuration file.

The value returned may be different from the length of the supplied string array of user names because some of the profiles are no longer found in the data source.

The delete profiles operation is a transactional operation. If an error is encountered, then the transaction is rolled back and no changes are made.

FindInactiveProfilesByUserName

This method retrieves inactive profile information for the specified user name.

Declaration

// C#
public override ProfileInfoCollection FindInactiveProfilesByUserName
   (ProfileAuthenticationOption profileAuthenticationOption, string userName,
   DateTime inactiveSinceDateTime,int pageIndex, int pageSize, 
   out int totalRecords);

Parameters

  • profileAuthenticationOption

    Anonymous, Authenticated, or All profiles to be searched to find inactive profiles.

  • userName

    The user name to match.

  • inactiveSinceDateTime

    The cut-off date and time that indicate a profile is inactive.

  • pageIndex

    The zero-based index of the results page.

  • pageSize

    The size of the page of the results page.

  • totalRecords

    The total number of profiles.

Return Value

A ProfileInfoCollection object that contains inactive user profiles where the user name matches the supplied user name.

Exceptions

ArgumentException - One of the following conditions exists:

  • The userName parameter is an empty string or exceeds 256 characters.

  • The pageSize parameter is less than 1.

  • The pageIndex parameter is less than 0 or pageIndex multiplied by pageSize is larger than the Int32.MaxValue.

ArgumentNullException - The userName parameter is a null reference.

Remarks

This method retrieves inactive profiles from the data source for the application specified by the applicationName attribute in the configuration file. The profileAuthenticationOption parameter specifies whether to search only anonymous profiles, only authenticated profiles, or all profiles. The OracleProfileProvider object searches for a match of the supplied userName parameter using the LIKE keyword and supports wildcard characters using the percent sign (%). This method retrieves profiles with a last activity date and time on or before the specified inactiveSinceDateTime parameter value.

The results returned by this method are constrained by the pageIndex and pageSize parameters. The pageSize parameter identifies the number of ProfileInfo objects to return in the ProfileInfoCollection object. The pageIndex parameter identifies which page of results to return. The totalRecords parameter is an out parameter for the total number of inactive user profiles that match the userName and inactiveSinceDateTime parameters.

FindProfilesByUserName

This method retrieves profile information for the specified user name.

Declaration

// C#
public override ProfileInfoCollection FindProfilesByUserName
  (ProfileAuthenticationOption profileAuthenticationOption, string userName, 
   int pageIndex, int pageSize, out int totalRecords);

Parameters

  • profileAuthenticationOption

    Anonymous, Authenticated, or All profiles to be searched to find active profiles.

  • userName

    The user name to match.

  • pageIndex

    The zero-based index of the results page.

  • pageSize

    The size of the page of results page.

  • totalRecords

    The total number of profiles.

Return Value

A ProfileInfoCollection object that contains user profiles where the user name matches the supplied user name.

Exceptions

ArgumentException - One of the following conditions exists:

  • The userName parameter is an empty string or exceeds 256 characters.

  • The pageSize parameter value is less than 1.

  • The pageIndex parameter value is less than 0 or pageIndex multiplied by pageSize is larger than Int32.MaxValue.

ArgumentNullException - The userName parameter is a null reference.

Remarks

This method retrieves profiles from the data source for the application specified by the applicationName attribute in the configuration file. The profileAuthenticationOption parameter specifies whether to search only anonymous profiles, only authenticated profiles, or all profiles. The OracleProfileProvider object searches for a match of the userName parameter supplied using the LIKE keyword and supports wildcard characters using the percent sign(% ).

The results returned by this method are constrained by the pageIndex and pageSize parameters. The pageSize parameter identifies the number of ProfileInfo objects to return in the ProfileInfoCollection object. The pageIndex parameter identifies which results page to return. The totalRecords parameter is an out parameter for the total number of inactive user profiles that matched the userName parameter.

GetAllInactiveProfiles

This method retrieves all profile information for profiles with the last activity date on or before the specified date and time.

Declaration

// C#
public override ProfileInfoCollection GetAllInactiveProfiles
   (ProfileAuthenticationOption profileAuthenticationOption, DateTime
   inactiveSinceDateTime, int pageIndex, int pageSize, out int totalRecords);

Parameters

  • profileAuthenticationOption

    Anonymous, Authenticated, or All profiles to be searched.

  • inactiveSinceDateTime

    The cut-off date and time that indicate a profile in inactive.

  • pageIndex

    The zero-based index of the results page.

  • pageSize

    The size of the page of the results page.

  • totalRecords

    The total number of profiles.

Return Value

A ProfileInfoCollection object that contains inactive user profiles that matches the supplied inactive date and time.

Exceptions

ArgumentException - One of the following conditions exists:

  • The pageSize parameter value is less than 1.

  • The pageIndex parameter value is less than 0 or pageIndex multiplied by pageSize is larger than Int32.MaxValue.

Remarks

This method retrieves inactive profiles from the data source for the application specified by the applicationName attribute in the configuration file. The profileAuthenticationOption parameter specifies whether to search only anonymous profiles, only authenticated profiles, or all profiles. This method retrieves profiles with a last activity date and time on or before the specified inactiveSinceDateTime parameter value.

The returned results are constrained by the pageIndex and pageSize parameters. The pageSize parameter identifies the number of ProfileInfo objects to return in the ProfileInfoCollection object. The pageIndex parameter identifies which page of results to return. Zero identifies the first page, as the value is zero-based. The totalRecords parameter is an out parameter for the total number of inactive user profiles that match the inactiveSinceDateTime parameter.

GetAllProfiles

This method retrieves all profile information from the data source.

Declaration

// C#
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption
   profileAuthenticationOption, int pageIndex, int pageSize,     out int totalRecords);

Parameters

  • profileAuthenticationOption

    Anonymous, Authenticated, or All profiles to be searched.

  • pageIndex

    The 0-based index of the results page.

  • pageSize

    The size of the page of the results page

  • totalRecords

    The total number of profiles.

Return Value

A ProfileInfoCollection object that contains all user profiles from the data source.

Exceptions

ArgumentException - One of the following conditions exists:

  • The pageSize parameter is less than 1.

  • The pageIndex parameter is less than 0 or pageIndex multiplied by pageSize is larger than Int32.MaxValue.

Remarks

This method retrieves all profiles from the data source for the application specified by the applicationName attribute in the configuration file. The profileAuthenticationOption parameter specifies whether to search only anonymous profiles, only authenticated profiles, or all profiles.

The returned results are constrained by the pageIndex and pageSize parameters. The pageSize parameter identifies the number of ProfileInfo objects to return in the ProfileInfoCollection object. The pageIndex parameter identifies which page of results to return. The totalRecords parameter is an out parameter for the total number of user profiles retrieved.

GetNumberOfInactiveProfiles

This method returns the count of profiles where the last activity date is on or before the specified date and time.

Declaration

// C#
public override int GetNumberOfInactiveProfiles
  (ProfileAuthenticationOption profileAuthenticationOption, 
   DateTime inactiveSinceDateTime);

Parameters

  • profileAuthenticationOption

    Anonymous, Authenticated, or All profiles to be searched.

  • inactiveSinceDateTime

    The cut-off date and time that indicate a profile is inactive.

Return Value

An integer value indicating the number of user profiles that match the inactive date and time supplied.

Remarks

This method returns a count of inactive profiles from the data source for the application specified by the applicationName attribute in the configuration file. The profileAuthenticationOption parameter specifies whether to search only anonymous profiles, only authenticated profiles, or all profiles. Of the searched user profiles, any profiles with a last activity date and time on or before the specified inactiveSinceDateTime parameter value are counted.

GetPropertyValues

This method retrieves profile properties and values from the Oracle profile database.

Declaration

// C#
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext   
  settingsContext, SettingsPropertyCollection settingsPropertyCollection);

Parameters

  • settingsContext

    The SettingsContext object that contains user profile information.

  • settingsPropertyCollection

    The SettingsPropertyCollection object that contains profile information for the properties to be retrieved.

Return Value

A SettingsPropertyValueCollection object that contains profile property information and values.

Remarks

This method retrieves profile properties and values from the Oracle database for the user profile specified by the context. Profile properties and values are returned as a collection of SettingsPropertyValue objects.

Initialize

This method initializes the OracleProfileProvider instance with the property values specified in the ASP.NET application configuration file (web.config).

Declaration

// C#
public override void Initialize(string name, NameValueCollection config);

Parameters

  • name

    The name of the OracleProfileProvider instance to initialize.

  • config

    A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for the provider.

Exceptions

ArgumentNullException - The config parameter is a null reference.

HttpException - The current trust level is less than Low.

InvalidOperationException - An attempt is made to call the Initialize method on a provider that has already been initialized.

ArgumentNullException - The config parameter is a null.

System.Configuration.Provider.ProviderException - One of the following conditions is true in the application configuration file:

  • The connectionStringName attribute is empty or does not exist in the application configuration file.

  • The value of the connection string for the connectionStringName attribute is empty or the specified connectionStringName value does not exist in the application configuration file.

  • The applicationName attribute value exceeds 256 characters.

  • The application configuration file for this OracleProfileProvider instance contains an unrecognized attribute.

Remarks

The Initialize method sets options and property values for the provider instance, including provider-specific values and options specified in the machine configuration file (machine.config) or the ASP.NET application configuration file (web.config).

The Initialize method is not intended to be called directly by the application.

SetPropertyValues

This method updates the Oracle profile database with the specified profile property values.

Declaration

// C#
public override void SetPropertyValues(SettingsContext settingsContext,
   SettingsPropertyValueCollection settingsPropertyValueCollection);

Parameters

  • settingsContext

    The SettingsContext object that contains user profile information.

  • settingsPropertyValueCollection

    A SettingsPropertyValueCollection object that contains profile information and values for updating the user profile properties.

Remarks

ASP.NET profile services use this method to update profile properties and values in the Oracle database for the user profile specified by the context.Property values are set at the data source for the application specified by the applicationName attribute in the configuration file. Profile properties and values to be updated are specified as a collection of SettingsPropertyValue objects.