Oracle® Providers for ASP.NET Developer's Guide 11g Release 2 (11.2.0.3) for Microsoft Windows Part Number E18737-02 |
|
|
PDF · Mobi · ePub |
OracleProfileProvider
enables ASP.NET developers to easily store Web site user profile information in an Oracle database.
System.Object
System.Configuration.Provider.ProviderBase
System.Configuration.SettingsProvider
System.Web.Profile.ProfileProvider
Oracle.Web.Profile.OracleProfileProvider
// C# public class OracleProfileProvider: ProfileProvider
All public static methods are thread-safe, although instance members are not guaranteed to be thread-safe.
This class allows ASP.NET applications to store and manage profile information in an Oracle database.
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.
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
See Also:
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 |
---|---|
Instantiates a new instance of the |
OracleProfileProvider Static Methods
OracleProfileProvider
static methods are listed in Table 6-2.
Table 6-2 OracleProfileProvider Static Methods
Static Methods | Description |
---|---|
|
Inherited from |
|
Inherited from |
OracleProfileProvider Public Properties
OracleProfileProvider
public properties are listed in Table 6-3.
Table 6-3 OracleProfileProvider Public Properties
Public Properties | Description |
---|---|
Gets or sets the name of the application that groups the profile information |
|
Gets the number of seconds that the command is allowed to execute before it is terminated with an exception |
|
|
Inherited from |
|
Inherited from |
OracleProfileProvider Public Methods
OracleProfileProvider
public methods are listed in Table 6-4.
Table 6-4 OracleProfileProvider Public Methods
Public Methods | Description |
---|---|
Deletes user profile data that has its last activity date on or before the specified date and time |
|
Deletes profile properties and information from the data source for the supplied profile collection or list of user names (Overloaded) |
|
|
Inherited from |
Retrieves inactive profile information for the specified user name |
|
Retrieves profile information for the specified user name |
|
Retrieves all profile information for profiles with the last activity date on or before the specified date and time |
|
Retrieves all profile information from the data source |
|
|
Inherited from |
Returns the count of profiles where the last activity date is on or before the specified date and time |
|
Retrieves profile properties and values from the Oracle profile database |
|
|
Inherited from |
Initializes the |
|
Updates the Oracle profile database with the specified profile property values |
|
|
Inherited from |
This constructor instantiates a new instance of the OracleProfileProvider
class.
This constructor creates an instance of the OracleProfileProvider
class.
See Also:
This constructor instantiates a new instance of the OracleProfileProvider
class.
// C# public OracleProfileProvider();
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.
See Also:
OracleProfileProvider
static methods are listed in Table 6-5.
Table 6-5 OracleProfileProvider Static Methods
Static Methods | Description |
---|---|
|
Inherited from |
|
Inherited from |
See Also:
OracleProfileProvider
public properties are listed in Table 6-6.
Table 6-6 OracleProfileProvider Public Properties
Public Properties | Description |
---|---|
Gets or sets the name of the application that groups the profile information |
|
Gets the number of seconds that the command is allowed to execute before it is terminated with an exception |
|
|
Inherited from |
|
Inherited from |
See Also:
This property gets or sets the name of the application that groups the profile information.
// C# public override string ApplicationName{get; set;}
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.
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.
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.
See Also:
This property gets the number of seconds that the command is allowed to execute before it is terminated with an exception.
// C# public int CommandTimeout {get;}
An int
.
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.
See Also:
OracleProfileProvider
public methods are listed in Table 6-7.
Table 6-7 OracleProfileProvider Public Methods
Public Methods | Description |
---|---|
Deletes user profile data that has its last activity date on or before the specified date and time |
|
Deletes profile properties and information from the data source for the supplied profile collection or list of user names (Overloaded) |
|
|
Inherited from |
Retrieves inactive profile information for the specified user name |
|
Retrieves profile information for the specified user name |
|
Retrieves all profile information for profiles with the last activity date on or before the specified date and time |
|
Retrieves all profile information from the data source |
|
|
Inherited from |
Returns the count of profiles where the last activity date is on or before the specified date and time |
|
Retrieves profile properties and values from the Oracle profile database |
|
|
Inherited from |
Initializes the |
|
Updates the Oracle profile database with the specified profile property values |
|
|
Inherited from |
See Also:
This method deletes user profile data that has its last activity date on or before the specified date and time.
// C# public override int DeleteInactiveProfiles(ProfileAuthenticationOption profileAuthenticationOption, DateTime inactiveSinceDateTime);
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.
An integer value that indicates the number of inactive profiles deleted from the data source.
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.
See Also:
This method deletes profile properties and information from the data source for the supplied profile collection or list of user names.
DeleteProfiles(ProfileInfoCollection)
This method deletes profile properties and information from the data source for the supplied profile collection.
This method deletes profile properties and information from the data source for the supplied list of user names.
See Also:
This method deletes profile properties and information from the data source for the supplied profile collection.
// C#
public override int DeleteProfiles(ProfileInfoCollection profileInfoCollection);
profileInfoCollection
A ProfileInfoCollection
object that contains profile information for profiles to be deleted.
An integer value indicating the number of profiles that were deleted from the data source.
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.
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.
See Also:
This method deletes profile properties and information from the data source for the supplied list of user names.
// C#
public override int DeleteProfiles(string[] userNames);
userNames
A string array of user names whose profiles are to be deleted.
An integer value indicating the number of profiles that were deleted from the data source.
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.
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.
See Also:
This method retrieves inactive profile information for the specified user name.
// C# public override ProfileInfoCollection FindInactiveProfilesByUserName (ProfileAuthenticationOption profileAuthenticationOption, string userName, DateTime inactiveSinceDateTime,int pageIndex, int pageSize, out int totalRecords);
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.
A ProfileInfoCollection
object that contains inactive user profiles where the user name matches the supplied user name.
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.
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.
See Also:
This method retrieves profile information for the specified user name.
// C# public override ProfileInfoCollection FindProfilesByUserName (ProfileAuthenticationOption profileAuthenticationOption, string userName, int pageIndex, int pageSize, out int totalRecords);
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.
A ProfileInfoCollection
object that contains user profiles where the user name matches the supplied user name.
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.
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.
See Also:
This method retrieves all profile information for profiles with the last activity date on or before the specified date and time.
// C# public override ProfileInfoCollection GetAllInactiveProfiles (ProfileAuthenticationOption profileAuthenticationOption, DateTime inactiveSinceDateTime, int pageIndex, int pageSize, out int totalRecords);
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.
A ProfileInfoCollection
object that contains inactive user profiles that matches the supplied inactive date and time.
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
.
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.
See Also:
This method retrieves all profile information from the data source.
// C# public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption profileAuthenticationOption, int pageIndex, int pageSize, out int totalRecords);
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.
A ProfileInfoCollection
object that contains all user profiles from the data source.
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
.
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.
See Also:
This method returns the count of profiles where the last activity date is on or before the specified date and time.
// C# public override int GetNumberOfInactiveProfiles (ProfileAuthenticationOption profileAuthenticationOption, DateTime inactiveSinceDateTime);
profileAuthenticationOption
Anonymous
, Authenticated
, or All
profiles to be searched.
inactiveSinceDateTime
The cut-off date and time that indicate a profile is inactive.
An integer value indicating the number of user profiles that match the inactive date and time supplied.
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.
See Also:
This method retrieves profile properties and values from the Oracle profile database.
// C# public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext settingsContext, SettingsPropertyCollection settingsPropertyCollection);
settingsContext
The SettingsContext
object that contains user profile information.
settingsPropertyCollection
The SettingsPropertyCollection
object that contains profile information for the properties to be retrieved.
A SettingsPropertyValueCollection
object that contains profile property information and values.
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.
See Also:
This method initializes the OracleProfileProvider
instance with the property values specified in the ASP.NET application configuration file (web.config
).
// C# public override void Initialize(string name, NameValueCollection config);
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.
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.
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.
See Also:
This method updates the Oracle profile database with the specified profile property values.
// C# public override void SetPropertyValues(SettingsContext settingsContext, SettingsPropertyValueCollection settingsPropertyValueCollection);
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.
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.