Skip Headers
Oracle® Providers for ASP.NET Developer's Guide
11g Release 2 (11.2.0.2.0) for Microsoft Windows

Part Number E18737-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

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

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

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:

ArgumentNullException - One of the following conditions exists:

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

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:

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

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:

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

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:

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

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:

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

Return Value

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

Exceptions

ArgumentException - One of the following conditions exists:

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

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

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

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:

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

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.