Im currently writing a custom Oracle Membership Provider. I have been able to get the login and createuser controls to work with my membership class, however, I cannot seem to get the changepassword control or PasswordRecovery to work. The overridable properties
of the Membership Class seem to have a few events which allow the password to be reset, however after implementing my custom code for these, it still does not work.
Below is my class.
Public Class OracleMemberShipProvider
Inherits MembershipProvider
REM For Oracle Data Access
Private cn As New OracleConnection(ConfigurationManager.ConnectionStrings("EXWEB").ConnectionString.ToString)
Private cmd As New OracleCommand
Private _requiresQuestionAndAnswer As Boolean
Private _minRequiredPasswordLength As Integer
Private _enablePasswordReset As Boolean
Public Overrides Sub Initialize(ByVal name As String, ByVal config As System.Collections.Specialized.NameValueCollection)
If config("requiresQuestionAndAnswer") = "true" Then _
_requiresQuestionAndAnswer = True
If config("enablePasswordReset") = "true" Then _
_enablePasswordReset = True
cmd.Connection = cn
MyBase.Initialize(name, config)
End Sub
Public Overrides Property ApplicationName() As String
Get
End Get
Set(ByVal value As String)
End Set
End Property
Public Overrides Function GetPassword(ByVal username As String, ByVal answer As String) As String
Try
cn.Open()
cmd.CommandText = "SELECT PASSWORD FROM ASPNET_MEMBERSHIP WHERE USERNAME = :username"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
Dim password As String = String.Empty
password = cmd.ExecuteScalar()
Return password
Catch ex As Exception
Return ""
cmd.Parameters.Clear()
cn.Close()
End Try
End Function
Public Overrides Function ChangePassword(ByVal username As String, ByVal oldPassword As String, ByVal newPassword As String) As Boolean
Try
cn.Open()
cmd.CommandText = "UPDATE ASPNET_MEMBERSHIP SET PASSWORD = :password WHERE USERNAME = :username AND PASSWORD = :oldpwd"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = newPassword
cmd.Parameters.Add("oldpwd", OracleType.VarChar).Value = oldPassword
cmd.ExecuteNonQuery()
Return True
Catch ex As Exception
cmd.Parameters.Clear()
cn.Close()
Return False
End Try
End Function
Public Overrides Function ChangePasswordQuestionAndAnswer(ByVal username As String, ByVal password As String, ByVal newPasswordQuestion As String, ByVal newPasswordAnswer As String) As Boolean
Try
cn.Open()
cmd.CommandText = "UPDATE ASPNET_MEMBERSHIP SET PASSWORDQUESTION = :pq, PASSWORDANSWER = :pa WHERE USERNAME = :username AND PASSWORD = :password"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = password
cmd.Parameters.Add("pq", OracleType.VarChar).Value = newPasswordQuestion
cmd.Parameters.Add("pa", OracleType.VarChar).Value = newPasswordAnswer
cmd.ExecuteNonQuery()
Return True
Catch ex As Exception
cmd.Parameters.Clear()
cn.Close()
Return False
End Try
End Function
Public Overrides Function CreateUser(ByVal username As String, ByVal password As String, ByVal email As String, ByVal passwordQuestion As String, ByVal passwordAnswer As String, ByVal isApproved As Boolean, ByVal providerUserKey As Object, ByRef status
As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser
Try
REM Check That the username does not exist
cmd.CommandText = "SELECT COUNT(*) FROM ASPNET_MEMBERSHIP WHERE UPPER(USERNAME) = upper(:username)"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cn.Open()
Dim rcount As Integer = cmd.ExecuteScalar()
cn.Close()
REM End Password check
If rcount = 0 Then
REM Check that the email is unique
cmd.CommandText = "SELECT COUNT(*) FROM ASPNET_MEMBERSHIP WHERE UPPER(EMAIL) = upper(:email)"
cmd.Parameters.Clear()
cmd.Parameters.Add("email", OracleType.VarChar).Value = email
cn.Open()
rcount = cmd.ExecuteScalar()
cn.Close()
REM End Email Check
If rcount = 0 Then
REM Attepmt to insert the user
Dim sql As String = "INSERT INTO ASPNET_MEMBERSHIP " & _
"(USERNAME, LOWEREDUSERNAME, PASSWORD, EMAIL, LOWEREDEMAIL, PASSWORDQUESTION, PASSWORDANSWER) " & _
"VALUES (" & _
":username, LOWER(:username), :password, :email, LOWER(:email), :passwordQuestion, :passwordAnswer)"
cmd.CommandText = sql
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = password
cmd.Parameters.Add("passwordQuestion", OracleType.VarChar).Value = passwordQuestion
cmd.Parameters.Add("passwordAnswer", OracleType.VarChar).Value = passwordAnswer
cn.Open()
Dim result As Integer = cmd.ExecuteNonQuery()
cn.Close()
status = MembershipCreateStatus.Success
Dim user As New MembershipUser("OracleMembershipProvider", username, Nothing, email, passwordQuestion, Nothing, True, False, Now, Nothing, Nothing, Nothing, Nothing)
Return user
REM End User Insert
Else
REM Alert of duplicate email
status = MembershipCreateStatus.DuplicateEmail
Return Nothing
End If
Else
REM Alert of duplicate username
status = MembershipCreateStatus.DuplicateUserName
Return Nothing
End If
Catch ex As OracleException
REM Alert of Provider Error
status = MembershipCreateStatus.ProviderError
Return Nothing
Finally
cn.Close()
cmd.Parameters.Clear()
End Try
End Function
Public Overrides Function DeleteUser(ByVal username As String, ByVal deleteAllRelatedData As Boolean) As Boolean
Try
cn.Open()
Dim sql As String = "DELETE FROM ASPNET_MEMBERSHIP WHERE USERID = " & _
"(SELECT USERID FROM ASPNET_MEMBERSHIP WHERE USERNAME = :username)"
cmd.CommandText = sql
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.ExecuteNonQuery()
cn.Close()
Return True
Catch ex As Exception
Return False
Finally
cn.Close()
cmd.Parameters.Clear()
End Try
End Function
Public Overrides ReadOnly Property EnablePasswordReset() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property EnablePasswordRetrieval() As Boolean
Get
Return True
End Get
End Property
Public Overrides Function FindUsersByEmail(ByVal emailToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New Exception("Not Implemented")
End Function
Public Overrides Function FindUsersByName(ByVal usernameToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New Exception("Not Implemented")
End Function
Public Overrides Function GetAllUsers(ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New Exception("Not Implemented")
End Function
Public Overrides Function GetNumberOfUsersOnline() As Integer
Throw New Exception("Not Implemented")
End Function
Public Overloads Overrides Function GetUser(ByVal username As String, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser
Throw New Exception("Not Implemented")
End Function
Public Overloads Overrides Function GetUser(ByVal providerUserKey As Object, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser
Throw New Exception("Not Implemented")
End Function
Public Overrides Function GetUserNameByEmail(ByVal email As String) As String
Throw New Exception("Not Implemented")
End Function
Public Overrides ReadOnly Property MaxInvalidPasswordAttempts() As Integer
Get
Return 3
End Get
End Property
Public Overrides ReadOnly Property MinRequiredNonAlphanumericCharacters() As Integer
Get
Return 1
End Get
End Property
Public Overrides ReadOnly Property MinRequiredPasswordLength() As Integer
Get
Return 8
End Get
End Property
Public Overrides ReadOnly Property PasswordAttemptWindow() As Integer
Get
Return 5
End Get
End Property
Public Overrides ReadOnly Property PasswordFormat() As System.Web.Security.MembershipPasswordFormat
Get
Return MembershipPasswordFormat.Clear
End Get
End Property
Public Overrides ReadOnly Property PasswordStrengthRegularExpression() As String
Get
End Get
End Property
Public Overrides ReadOnly Property RequiresQuestionAndAnswer() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property RequiresUniqueEmail() As Boolean
Get
Return True
End Get
End Property
Public Overrides Function ResetPassword(ByVal username As String, ByVal answer As String) As String
Throw New Exception("Not Implemented")
End Function
Public Overrides Function UnlockUser(ByVal userName As String) As Boolean
Throw New Exception("Not Implemented")
End Function
Public Overrides Sub UpdateUser(ByVal user As System.Web.Security.MembershipUser)
Throw New Exception("Not Implemented")
End Sub
Public Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean
Try
cn.Open()
Dim sql As String = "Select * From ASPNET_MEMBERSHIP WHERE " & _
"username=:username AND password=:password"
cmd.CommandText = sql
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = password
Dim reader As OracleDataReader = cmd.ExecuteReader
If reader.HasRows Then
Return True
Else
Return False
End If
Catch ex As Exception
Console.Write(ex.ToString)
Return False
Finally
cn.Close()
cmd.Parameters.Clear()
End Try
End Function
Can anyone give me any idea why this is not working and what i could be missing? I cannot seem to identify which event is being called from the class when the changepassword control or password retreival controls are invoked. I have also ensured that the
Membership proider property of all the controls is set to OracleMemberShipProvider as specified in the web config.
Maybe someone would like to join with me to create an Oracle Provider, I have the DB schema etc already defined which is highly similar to the SQLServer provider DB that is generated by ASP.NET.
You have got everything work right. Just add the EnablePasswordRetrieval property to the class,
web.config and perform a check in the Initialize function.
MSDN says......
<<<The EnablePasswordRetrieval property indicates whether users can retrieve their password using the
GetPassword method.>>>
public override
bool ChangePasswordQuestionAndAnswer(string username,
string password,
string newPasswordQuestion,
string newPasswordAnswer)
public override
bool ChangePassword(string username,
string oldPassword,
string newPassword)
Its been a few months since I worked on this model and currently dont remember the exact flow of events. Try to implement the other function and check if it works.
Its not been a good day for me. My apologies for the crappiest reply ever.....
I have the OracleMemberShip Provider code in C#. Can u send me your email address ?
Here is a small piece of it.....
public override
void Initialize(string name,
NameValueCollection config)
{
//////Verify that config isn't null
if (config ==
null)
throw new
ArgumentNullException("configs");
// Assign "name" a default value if it currently has no value
// or is an empty string
if (String.IsNullOrEmpty(name))
name =
"OracleMembershipProvider";
// Add a default "description" attribute to config if the
// attribute doesn't exist or is empty
if (string.IsNullOrEmpty(config["description"]))
{
config.Remove(
"description");
config.Add(
"description",
"MembershipProvider");
}
// Call the base class's Initialize method
base.Initialize(name, config);
//Get the required values from Web.Config.If the values are not mentioned in web.config,
//initialze them to default values
SecUtil.GetIntValue(config,
"minRequiredNonalphanumericCharacters", 1,
true, 128);
////////////////////////////////////////////////////////////////////////
//Set the default HashAlgorithm type to 'SHA1',if null
_HashAlgorithmType = config[
"hashAlgorithmType"];
if (String.IsNullOrEmpty(_HashAlgorithmType))
{
_HashAlgorithmType =
"SHA1";
}
//Set the default value of PasswordStrengthRegularExpression to empty string,if null
_PasswordStrengthRegularExpression = config[
"passwordStrengthRegularExpression"];
if (_PasswordStrengthRegularExpression !=
null)
if (_PasswordStrengthRegularExpression.Length != 0)
{
try
{
Regex regex =
new Regex(_PasswordStrengthRegularExpression);
}
catch (ArgumentException e)
{
throw new
ProviderException(e.Message, e);
}
}
}
else
{
_PasswordStrengthRegularExpression =
string.Empty;
}
//Set the default password format to Hashed,if not present
string strTemp = config["passwordFormat"];
if (strTemp ==
null)
strTemp =
"Hashed";
switch (strTemp)
{
case "Clear":
_PasswordFormat =
MembershipPasswordFormat.Clear;
break;
case "Encrypted":
_PasswordFormat =
MembershipPasswordFormat.Encrypted;
break;
case "Hashed":
_PasswordFormat =
MembershipPasswordFormat.Hashed;
break;
default:
throw new
ProviderException("Bad password format");
}
//Password cannot be retrived if it is hashed
if (_PasswordFormat ==
MembershipPasswordFormat.Hashed && _EnablePasswordRetrieval)
throw new
ProviderException("Provider cannot retrieve hashed password");
/////////////////////////////////////////////////////////////////
//validate application name
_AppName = config[
"applicationName"];
if (string.IsNullOrEmpty(_AppName))
_AppName =
"/";
if (_AppName.Length > 255)
{
throw new
ProviderException("Provider application name is too long, max length is 255.");
}
/////////////////////////////////////////////////////////////////
// Initialize _connectionStringName from the connectionStringName
// configuration attribute, or throw an exception if the attribute
// doesn't exist or is an empty string, or if it designates a
// nonexistent connection string
_ConnectionString =
"Data Source=oracle;Persist Security Info=True;User ID=naveenl;Password=cis761;Unicode=True";
if (string.IsNullOrEmpty(_ConnectionString))
{
throw new
ProviderException("Provider connection name is null or empty");
}
//ConnectionStringSettings connObj = ConfigurationManager.ConnectionStrings[_ConnectionString];
//ConnectionStringSettings connObj = "Data Source=oracle;Persist Security Info=True;User ID=naveenl;Password=cis761;Unicode=True";
//if (connObj == null)
//{
// throw new ProviderException("Connection name not specified");
//}
if (user_id.Equals(null))
throw new
ProviderException("user id cannot be null");
//////////////////////////////////////////////////////////////////
//Remove the recognized values from config
config.Remove(
"connectionStringName");
config.Remove(
"enablePasswordRetrieval");
config.Remove(
"enablePasswordReset");
config.Remove(
"requiresQuestionAndAnswer");
config.Remove(
"applicationName");
config.Remove(
"requiresUniqueEmail");
config.Remove(
"maxInvalidPasswordAttempts");
config.Remove(
"passwordAttemptWindow");
config.Remove(
"passwordFormat");
config.Remove(
"minRequiredPasswordLength");
config.Remove(
"minRequiredNonalphanumericCharacters");
config.Remove(
"passwordStrengthRegularExpression");
config.Remove(
"hashAlgorithmType");
config.Remove(
"description");
//Throw an exception ,if the Element used to register the provider contains
//one or more unrecognized configuration attributes
if (config.Count > 0)
{
string attribUnrecognized = config.GetKey(0);
if (!String.IsNullOrEmpty(attribUnrecognized))
throw new
ProviderException("Provider unrecognized attribute: " + attribUnrecognized);
}
/////////////////////////////////////////////////////////
/////Validate each of the MembershipProvider tables i.e. Provider_Applications ,
////Provider_Users,Provider_Users tables and verify if they exist or not
////If they exist check for the datatypes of the fields of each table
////If the tables do not exist create the tables,triggers and sequences.
////If the sequences already exist,exception is thrown
if (!OracleProviderSchema.ValidateApplicationsTable(oracleConnection, oracleApplicationsTable, user_id))
{
throw new
ProviderException("Provider_Applications table validation error");
}
if (!OracleProviderSchema.ValidateUsersTable(oracleConnection, oracleUsersTable, user_id))
{
throw new
ProviderException("Provider_Users table validation error");
}
if (!OracleProviderSchema.ValidateMembershipTable(oracleConnection, oracleMembershipTable, user_id))
{
throw new
ProviderException("Provider_Users table valdation error");
}
}
#endregion
Override the ProviderBase Initialize function
#region
Functions for User Creation,Deletion,Validation and Updation
///
<summary>
/// This function is invoked by the CreateUser wizard.
/// The CreateUser function returns a membershipuser object containing the details of the user ,if user is created successfully.
/// It creates an applicationID if it does not exist and also creates the UserID in the Provider_Users table,if the username does not exist.
/// Depending on the _RequireUniqueEmail parameter,it generates an error if the email is duplicate.Since this function contains many update
/// statements,upon the failure of any one update statement,the transaction is rolled back.
///
</summary>
///
<param name="username">Username of the user</param>
///
<param name="password">Password of the user</param>
///
<param name="email">Email of the user</param>
///
<param name="passwordQuestion">Password question to retrieve the password</param>
///
<param name="passwordAnswer">Password answer to retrieve the password</param>
///
<param name="isApproved">Indicates if the user is approved or not</param>
///
<param name="UserID">Must be null,intially</param>
///
<param name="status">Status of creation of the user</param>
///
<returns>Memberhipuser object containing the user details</returns>
public override System.Web.Security.MembershipUser CreateUser(string
username, string password,
string email,
string passwordQuestion,
string passwordAnswer,
bool isApproved, object UserID,
out System.Web.Security.MembershipCreateStatus status)
{
//Username and Email should be lower case
username = username.ToLower();
email = email.ToLower();
//validate the parameters username,password,email,passwordQuestion,passwordAnswer
if (!SecUtil.ValidateParameter(ref password,
true,
true,
false,
///Generates a cryptographic Random Number encoded into a base 64 digit string
///Salt is used for encoding the pasword.
string salt = GenerateSalt();
//passwoed is encoded
string pass = EncodePassword(password, (int)_PasswordFormat, salt);
if (pass.Length > 128)
/////////////////////////////////////////////////////////
//---initialize Local variables---//
DateTime dt_rollback =
new DateTime();
int appId;
int uid = 0;
bool fBeginTransCalled =
false;
/////////////////////////////////////////////////////////
//
//Begin the transaction
//
fBeginTransCalled =
true;
user_connection.Open();
/////////////////////////////////////////////////////////
//Step 1: Get ApplicationID or create one if ApplicationID does not exist's
appId = GetAppplicationId(user_connection,
out ApplicationID_Creation);
/////////////////////////////////////////////////////////////////
// Step 2: Check if the user exists in the Users table: create if not
uid = GetUserID(user_connection, appId, username,
true,
false, DateTime.Now,
out UserId_Creation);
if (uid == 0)
{
/////////////////////////////////////////////////////////
// User not created successfully!
////////////////////////////////////////////////////////////
// Step 3: Check if the user exists in the Membership table: Error if yes.
OracleCommand command =
new OracleCommand("SELECT UserId FROM PROVIDER_MEMBERSHIP WHERE USERID = :UserId",
user_connection);
command.Parameters.AddWithValue(
":UserId", uid);
int result =
Convert.ToInt32(command.ExecuteScalar());
if (result != 0)
////////////////////////////////////////////////////////////
// Step 4: Check if Email is duplicate
if (RequiresUniqueEmail)
{
command =
new
OracleCommand("SELECT u.UserId FROM PROVIDER_MEMBERSHIP m, PROVIDER_USERS u WHERE u.ApplicationId = :AppId AND m.UserId = u.UserId AND m.Email = :Email",
user_connection);
command.Parameters.AddWithValue(
"AppId", appId);
command.Parameters.AddWithValue(
"Email", email);
result =
Convert.ToInt32(command.ExecuteScalar());
if (result != 0)
Hi just to let you know I have figured out what was wrong. One of my methods was not implemented that I did not know that the change password method relied on. Therefore I have nearly finished the complete Membership Provider for Oracle. I have tested
it and it fully integrates well with Visual Studio Web Configurator and also has a custom Roles Provider to match. All is coded in VB.NET and I will be posting it online after I have concluded documentation of it along with Oracle DDL scripts to create the
tables etc. If your interested in obtaining it you can email me at
damianyoung@onetel.net as I know how hard it was to find material on creating a custom class.
I am working in ASP.NET 2.0 , C# with Oracle in backend. I am looking for C# OracleMembershipProvider. It definitely is a tremendous job. Can you please email me the code.
Ill be puttin the code online along with the DB schema which replicates the ASP.NET SQL db which is created. However some column names etc had to me ammened due to column name sizes in Oracle.
Ill post the link and demo next week when i tidy the code up a little.
My boss wants to implement the complete providers (Membership, Role, Session State, Web Event, etc.) in Oracle. After doing some research it appears to be a trememdous job. Does anyone know of a good commercial one that we can buy off the shelf?
diehardguy
Member
318 Points
72 Posts
Custom Oracle Membership Provider
Dec 27, 2006 11:19 AM|LINK
Hi all,
Im currently writing a custom Oracle Membership Provider. I have been able to get the login and createuser controls to work with my membership class, however, I cannot seem to get the changepassword control or PasswordRecovery to work. The overridable properties of the Membership Class seem to have a few events which allow the password to be reset, however after implementing my custom code for these, it still does not work. Below is my class.
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OracleClient
Imports System.Web.Security
Public Class OracleMemberShipProvider
Inherits MembershipProvider
REM For Oracle Data Access
Private cn As New OracleConnection(ConfigurationManager.ConnectionStrings("EXWEB").ConnectionString.ToString)
Private cmd As New OracleCommand
Private _requiresQuestionAndAnswer As Boolean
Private _minRequiredPasswordLength As Integer
Private _enablePasswordReset As Boolean
Public Overrides Sub Initialize(ByVal name As String, ByVal config As System.Collections.Specialized.NameValueCollection)
If config("requiresQuestionAndAnswer") = "true" Then _
_requiresQuestionAndAnswer = True
If config("enablePasswordReset") = "true" Then _
_enablePasswordReset = True
cmd.Connection = cn
MyBase.Initialize(name, config)
End Sub
Public Overrides Property ApplicationName() As String
Get
End Get
Set(ByVal value As String)
End Set
End Property
Public Overrides Function GetPassword(ByVal username As String, ByVal answer As String) As String
Try
cn.Open()
cmd.CommandText = "SELECT PASSWORD FROM ASPNET_MEMBERSHIP WHERE USERNAME = :username"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
Dim password As String = String.Empty
password = cmd.ExecuteScalar()
Return password
Catch ex As Exception
Return ""
cmd.Parameters.Clear()
cn.Close()
End Try
End Function
Public Overrides Function ChangePassword(ByVal username As String, ByVal oldPassword As String, ByVal newPassword As String) As Boolean
Try
cn.Open()
cmd.CommandText = "UPDATE ASPNET_MEMBERSHIP SET PASSWORD = :password WHERE USERNAME = :username AND PASSWORD = :oldpwd"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = newPassword
cmd.Parameters.Add("oldpwd", OracleType.VarChar).Value = oldPassword
cmd.ExecuteNonQuery()
Return True
Catch ex As Exception
cmd.Parameters.Clear()
cn.Close()
Return False
End Try
End Function
Public Overrides Function ChangePasswordQuestionAndAnswer(ByVal username As String, ByVal password As String, ByVal newPasswordQuestion As String, ByVal newPasswordAnswer As String) As Boolean
Try
cn.Open()
cmd.CommandText = "UPDATE ASPNET_MEMBERSHIP SET PASSWORDQUESTION = :pq, PASSWORDANSWER = :pa WHERE USERNAME = :username AND PASSWORD = :password"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = password
cmd.Parameters.Add("pq", OracleType.VarChar).Value = newPasswordQuestion
cmd.Parameters.Add("pa", OracleType.VarChar).Value = newPasswordAnswer
cmd.ExecuteNonQuery()
Return True
Catch ex As Exception
cmd.Parameters.Clear()
cn.Close()
Return False
End Try
End Function
Public Overrides Function CreateUser(ByVal username As String, ByVal password As String, ByVal email As String, ByVal passwordQuestion As String, ByVal passwordAnswer As String, ByVal isApproved As Boolean, ByVal providerUserKey As Object, ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser
Try
REM Check That the username does not exist
cmd.CommandText = "SELECT COUNT(*) FROM ASPNET_MEMBERSHIP WHERE UPPER(USERNAME) = upper(:username)"
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cn.Open()
Dim rcount As Integer = cmd.ExecuteScalar()
cn.Close()
REM End Password check
If rcount = 0 Then
REM Check that the email is unique
cmd.CommandText = "SELECT COUNT(*) FROM ASPNET_MEMBERSHIP WHERE UPPER(EMAIL) = upper(:email)"
cmd.Parameters.Clear()
cmd.Parameters.Add("email", OracleType.VarChar).Value = email
cn.Open()
rcount = cmd.ExecuteScalar()
cn.Close()
REM End Email Check
If rcount = 0 Then
REM Attepmt to insert the user
Dim sql As String = "INSERT INTO ASPNET_MEMBERSHIP " & _
"(USERNAME, LOWEREDUSERNAME, PASSWORD, EMAIL, LOWEREDEMAIL, PASSWORDQUESTION, PASSWORDANSWER) " & _
"VALUES (" & _
":username, LOWER(:username), :password, :email, LOWER(:email), :passwordQuestion, :passwordAnswer)"
cmd.CommandText = sql
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = password
cmd.Parameters.Add("passwordQuestion", OracleType.VarChar).Value = passwordQuestion
cmd.Parameters.Add("passwordAnswer", OracleType.VarChar).Value = passwordAnswer
cn.Open()
Dim result As Integer = cmd.ExecuteNonQuery()
cn.Close()
status = MembershipCreateStatus.Success
Dim user As New MembershipUser("OracleMembershipProvider", username, Nothing, email, passwordQuestion, Nothing, True, False, Now, Nothing, Nothing, Nothing, Nothing)
Return user
REM End User Insert
Else
REM Alert of duplicate email
status = MembershipCreateStatus.DuplicateEmail
Return Nothing
End If
Else
REM Alert of duplicate username
status = MembershipCreateStatus.DuplicateUserName
Return Nothing
End If
Catch ex As OracleException
REM Alert of Provider Error
status = MembershipCreateStatus.ProviderError
Return Nothing
Finally
cn.Close()
cmd.Parameters.Clear()
End Try
End Function
Public Overrides Function DeleteUser(ByVal username As String, ByVal deleteAllRelatedData As Boolean) As Boolean
Try
cn.Open()
Dim sql As String = "DELETE FROM ASPNET_MEMBERSHIP WHERE USERID = " & _
"(SELECT USERID FROM ASPNET_MEMBERSHIP WHERE USERNAME = :username)"
cmd.CommandText = sql
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.ExecuteNonQuery()
cn.Close()
Return True
Catch ex As Exception
Return False
Finally
cn.Close()
cmd.Parameters.Clear()
End Try
End Function
Public Overrides ReadOnly Property EnablePasswordReset() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property EnablePasswordRetrieval() As Boolean
Get
Return True
End Get
End Property
Public Overrides Function FindUsersByEmail(ByVal emailToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New Exception("Not Implemented")
End Function
Public Overrides Function FindUsersByName(ByVal usernameToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New Exception("Not Implemented")
End Function
Public Overrides Function GetAllUsers(ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New Exception("Not Implemented")
End Function
Public Overrides Function GetNumberOfUsersOnline() As Integer
Throw New Exception("Not Implemented")
End Function
Public Overloads Overrides Function GetUser(ByVal username As String, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser
Throw New Exception("Not Implemented")
End Function
Public Overloads Overrides Function GetUser(ByVal providerUserKey As Object, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser
Throw New Exception("Not Implemented")
End Function
Public Overrides Function GetUserNameByEmail(ByVal email As String) As String
Throw New Exception("Not Implemented")
End Function
Public Overrides ReadOnly Property MaxInvalidPasswordAttempts() As Integer
Get
Return 3
End Get
End Property
Public Overrides ReadOnly Property MinRequiredNonAlphanumericCharacters() As Integer
Get
Return 1
End Get
End Property
Public Overrides ReadOnly Property MinRequiredPasswordLength() As Integer
Get
Return 8
End Get
End Property
Public Overrides ReadOnly Property PasswordAttemptWindow() As Integer
Get
Return 5
End Get
End Property
Public Overrides ReadOnly Property PasswordFormat() As System.Web.Security.MembershipPasswordFormat
Get
Return MembershipPasswordFormat.Clear
End Get
End Property
Public Overrides ReadOnly Property PasswordStrengthRegularExpression() As String
Get
End Get
End Property
Public Overrides ReadOnly Property RequiresQuestionAndAnswer() As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property RequiresUniqueEmail() As Boolean
Get
Return True
End Get
End Property
Public Overrides Function ResetPassword(ByVal username As String, ByVal answer As String) As String
Throw New Exception("Not Implemented")
End Function
Public Overrides Function UnlockUser(ByVal userName As String) As Boolean
Throw New Exception("Not Implemented")
End Function
Public Overrides Sub UpdateUser(ByVal user As System.Web.Security.MembershipUser)
Throw New Exception("Not Implemented")
End Sub
Public Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean
Try
cn.Open()
Dim sql As String = "Select * From ASPNET_MEMBERSHIP WHERE " & _
"username=:username AND password=:password"
cmd.CommandText = sql
cmd.Parameters.Add("username", OracleType.VarChar).Value = username
cmd.Parameters.Add("password", OracleType.VarChar).Value = password
Dim reader As OracleDataReader = cmd.ExecuteReader
If reader.HasRows Then
Return True
Else
Return False
End If
Catch ex As Exception
Console.Write(ex.ToString)
Return False
Finally
cn.Close()
cmd.Parameters.Clear()
End Try
End Function
End Class
Heres My Web Config
<membership defaultProvider="OracleMemberShipProvider" >
<providers>
<add name="OracleMemberShipProvider"
type="OracleMemberShipProvider"
requiresQuestionAndAnswer="true"
enablePasswordReset="true"
connectionStringName="EXWEB"
providername="System.Data.OracleClient"
/>
</providers>
</membership>
Can anyone give me any idea why this is not working and what i could be missing? I cannot seem to identify which event is being called from the class when the changepassword control or password retreival controls are invoked. I have also ensured that the Membership proider property of all the controls is set to OracleMemberShipProvider as specified in the web config.
Maybe someone would like to join with me to create an Oracle Provider, I have the DB schema etc already defined which is highly similar to the SQLServer provider DB that is generated by ASP.NET.
Thanks In Advance
MCP
wildcats
Member
116 Points
26 Posts
Re: Custom Oracle Membership Provider
Dec 27, 2006 01:18 PM|LINK
You have got everything work right. Just add the EnablePasswordRetrieval property to the class, web.config and perform a check in the Initialize function.
MSDN says......
<<<The EnablePasswordRetrieval property indicates whether users can retrieve their password using the GetPassword method.>>>
Let me know, if this helps.
Cheers,
PP
diehardguy
Member
318 Points
72 Posts
Re: Custom Oracle Membership Provider
Dec 28, 2006 12:41 AM|LINK
Hi,
I dont know how this will solve my problem as within my class you will see that I have already set this to true in the GET and SET Properties.
Or is there something else im missing. Help!
MCP
wildcats
Member
116 Points
26 Posts
Re: Custom Oracle Membership Provider
Dec 28, 2006 12:55 AM|LINK
I missed it. Apologise for the previous one.
There are two functions for change password:
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) public override bool ChangePassword(string username, string oldPassword, string newPassword)Its been a few months since I worked on this model and currently dont remember the exact flow of events. Try to implement the other function and check if it works.
Hope this helps.
-PP
wildcats
Member
116 Points
26 Posts
Re: Custom Oracle Membership Provider
Dec 28, 2006 01:17 AM|LINK
Its not been a good day for me. My apologies for the crappiest reply ever.....
I have the OracleMemberShip Provider code in C#. Can u send me your email address ?
Here is a small piece of it.....
public override void Initialize(string name, NameValueCollection config){
//////Verify that config isn't null if (config == null) throw new ArgumentNullException("configs"); // Assign "name" a default value if it currently has no value // or is an empty string if (String.IsNullOrEmpty(name))name =
"OracleMembershipProvider"; // Add a default "description" attribute to config if the // attribute doesn't exist or is empty if (string.IsNullOrEmpty(config["description"])){
config.Remove(
"description");config.Add(
"description", "MembershipProvider");}
// Call the base class's Initialize method base.Initialize(name, config); //Get the required values from Web.Config.If the values are not mentioned in web.config, //initialze them to default values_EnablePasswordRetrieval =
SecUtil.GetBooleanValue(config, "enablePasswordRetrieval", false);_EnablePasswordReset =
SecUtil.GetBooleanValue(config, "enablePasswordReset", true);_RequiresQuestionAndAnswer =
SecUtil.GetBooleanValue(config, "requiresQuestionAndAnswer", true);_RequiresUniqueEmail =
SecUtil.GetBooleanValue(config, "requiresUniqueEmail", true);_MaxInvalidPasswordAttempts =
SecUtil.GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);_PasswordAttemptWindow =
SecUtil.GetIntValue(config, "passwordAttemptWindow", 10, false, 0);_MinRequiredPasswordLength =
SecUtil.GetIntValue(config, "minRequiredPasswordLength", 7, false, 128);_MinRequiredNonalphanumericCharacters =
SecUtil.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 128); //////////////////////////////////////////////////////////////////////// //Set the default HashAlgorithm type to 'SHA1',if null_HashAlgorithmType = config[
"hashAlgorithmType"]; if (String.IsNullOrEmpty(_HashAlgorithmType)){
_HashAlgorithmType =
"SHA1";}
//Set the default value of PasswordStrengthRegularExpression to empty string,if null_PasswordStrengthRegularExpression = config[
"passwordStrengthRegularExpression"]; if (_PasswordStrengthRegularExpression != null){
_PasswordStrengthRegularExpression = _PasswordStrengthRegularExpression.Trim();
if (_PasswordStrengthRegularExpression.Length != 0){
try{
Regex regex = new Regex(_PasswordStrengthRegularExpression);}
catch (ArgumentException e){
throw new ProviderException(e.Message, e);}
}
}
else{
_PasswordStrengthRegularExpression =
string.Empty;}
//Set the default password format to Hashed,if not present string strTemp = config["passwordFormat"]; if (strTemp == null)strTemp =
"Hashed"; switch (strTemp){
case "Clear":_PasswordFormat =
MembershipPasswordFormat.Clear; break; case "Encrypted":_PasswordFormat =
MembershipPasswordFormat.Encrypted; break; case "Hashed":_PasswordFormat =
MembershipPasswordFormat.Hashed; break; default: throw new ProviderException("Bad password format");}
//Password cannot be retrived if it is hashed if (_PasswordFormat == MembershipPasswordFormat.Hashed && _EnablePasswordRetrieval) throw new ProviderException("Provider cannot retrieve hashed password"); ///////////////////////////////////////////////////////////////// //validate application name_AppName = config[
"applicationName"]; if (string.IsNullOrEmpty(_AppName))_AppName =
"/"; if (_AppName.Length > 255){
throw new ProviderException("Provider application name is too long, max length is 255.");}
///////////////////////////////////////////////////////////////// // Initialize _connectionStringName from the connectionStringName // configuration attribute, or throw an exception if the attribute // doesn't exist or is an empty string, or if it designates a // nonexistent connection string_ConnectionString =
"Data Source=oracle;Persist Security Info=True;User ID=naveenl;Password=cis761;Unicode=True"; if (string.IsNullOrEmpty(_ConnectionString)){
throw new ProviderException("Provider connection name is null or empty");}
//ConnectionStringSettings connObj = ConfigurationManager.ConnectionStrings[_ConnectionString]; //ConnectionStringSettings connObj = "Data Source=oracle;Persist Security Info=True;User ID=naveenl;Password=cis761;Unicode=True"; //if (connObj == null) //{ // throw new ProviderException("Connection name not specified"); //}_ConnectionString =
"Data Source=oracle;Persist Security Info=True;User ID=naveenl;Password=cis761;Unicode=True";System.Data.OracleClient.
OracleConnection oracleConnection = new System.Data.OracleClient.OracleConnection();oracleConnection.ConnectionString = _ConnectionString;
///////////////////////////////////////////////////////// //Get the user id from the connection string for creating tablesuser_id = FindUserId(_ConnectionString).ToUpper();
if (user_id.Equals(null)) throw new ProviderException("user id cannot be null"); ////////////////////////////////////////////////////////////////// //Remove the recognized values from configconfig.Remove(
"connectionStringName");config.Remove(
"enablePasswordRetrieval");config.Remove(
"enablePasswordReset");config.Remove(
"requiresQuestionAndAnswer");config.Remove(
"applicationName");config.Remove(
"requiresUniqueEmail");config.Remove(
"maxInvalidPasswordAttempts");config.Remove(
"passwordAttemptWindow");config.Remove(
"passwordFormat");config.Remove(
"minRequiredPasswordLength");config.Remove(
"minRequiredNonalphanumericCharacters");config.Remove(
"passwordStrengthRegularExpression");config.Remove(
"hashAlgorithmType");config.Remove(
"description"); //Throw an exception ,if the Element used to register the provider contains //one or more unrecognized configuration attributes if (config.Count > 0){
string attribUnrecognized = config.GetKey(0); if (!String.IsNullOrEmpty(attribUnrecognized)) throw new ProviderException("Provider unrecognized attribute: " + attribUnrecognized);}
///////////////////////////////////////////////////////// /////Validate each of the MembershipProvider tables i.e. Provider_Applications , ////Provider_Users,Provider_Users tables and verify if they exist or not ////If they exist check for the datatypes of the fields of each table ////If the tables do not exist create the tables,triggers and sequences. ////If the sequences already exist,exception is thrown if (!OracleProviderSchema.ValidateApplicationsTable(oracleConnection, oracleApplicationsTable, user_id)){
throw new ProviderException("Provider_Applications table validation error");}
if (!OracleProviderSchema.ValidateUsersTable(oracleConnection, oracleUsersTable, user_id)){
throw new ProviderException("Provider_Users table validation error");}
if (!OracleProviderSchema.ValidateMembershipTable(oracleConnection, oracleMembershipTable, user_id)){
throw new ProviderException("Provider_Users table valdation error");}
}
#endregion
Override the ProviderBase Initialize function#region
Functions for User Creation,Deletion,Validation and Updation /// <summary> /// This function is invoked by the CreateUser wizard. /// The CreateUser function returns a membershipuser object containing the details of the user ,if user is created successfully. /// It creates an applicationID if it does not exist and also creates the UserID in the Provider_Users table,if the username does not exist. /// Depending on the _RequireUniqueEmail parameter,it generates an error if the email is duplicate.Since this function contains many update /// statements,upon the failure of any one update statement,the transaction is rolled back. /// </summary> /// <param name="username">Username of the user</param> /// <param name="password">Password of the user</param> /// <param name="email">Email of the user</param> /// <param name="passwordQuestion">Password question to retrieve the password</param> /// <param name="passwordAnswer">Password answer to retrieve the password</param> /// <param name="isApproved">Indicates if the user is approved or not</param> /// <param name="UserID">Must be null,intially</param> /// <param name="status">Status of creation of the user</param> /// <returns>Memberhipuser object containing the user details</returns> public override System.Web.Security.MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object UserID, out System.Web.Security.MembershipCreateStatus status){
//Username and Email should be lower caseusername = username.ToLower();
email = email.ToLower();
//validate the parameters username,password,email,passwordQuestion,passwordAnswer if (!SecUtil.ValidateParameter(ref password, true, true, false,0))
{
status =
MembershipCreateStatus.InvalidPassword; return null;}
///Generates a cryptographic Random Number encoded into a base 64 digit string ///Salt is used for encoding the pasword. string salt = GenerateSalt(); //passwoed is encoded string pass = EncodePassword(password, (int)_PasswordFormat, salt); if (pass.Length > 128){
status =
MembershipCreateStatus.InvalidPassword; return null;}
if (!SecUtil.ValidateParameter(ref username, true, true, true,255))
{
status =
MembershipCreateStatus.InvalidUserName; return null;}
if (!SecUtil.ValidateParameter(ref email,RequiresUniqueEmail,
RequiresUniqueEmail,
false,128))
{
status =
MembershipCreateStatus.InvalidEmail; return null;}
if (email.IndexOf('.') < 1 || email.IndexOf('@') < 1){
status =
MembershipCreateStatus.InvalidEmail; return null;}
if (!SecUtil.ValidateParameter(ref passwordQuestion,RequiresQuestionAndAnswer,
true, false,255))
{
status =
MembershipCreateStatus.InvalidQuestion; return null;}
if (!SecUtil.ValidateParameter(ref passwordAnswer,RequiresQuestionAndAnswer,
true, false,128))
{
status =
MembershipCreateStatus.InvalidAnswer; return null;}
///////////////////////////////////////////////////////// //UserID should be null for creating a user if (UserID != null){
throw new ArgumentException("userId Parameter must be null");}
///////////////////////////////////////////////////////// //Create a connection OracleConnection user_connection = new OracleConnection();user_connection.ConnectionString = _ConnectionString;
///////////////////////////////////////////////////////// //---initialize Local variables---// DateTime dt_rollback = new DateTime(); int appId; int uid = 0; bool fBeginTransCalled = false;ApplicationID_Creation =
false;UserId_Creation =
false;User_Creation =
false;User_Creation_timeupdate =
false; //Local variables---// ///////////////////////////////////////////////////////// try{
try{
///////////////////////////////////////////////////////// // //Begin the transaction //fBeginTransCalled =
true;user_connection.Open();
///////////////////////////////////////////////////////// //Step 1: Get ApplicationID or create one if ApplicationID does not exist'sappId = GetAppplicationId(user_connection,
out ApplicationID_Creation); ///////////////////////////////////////////////////////////////// // Step 2: Check if the user exists in the Users table: create if notuid = GetUserID(user_connection, appId, username,
true, false, DateTime.Now, out UserId_Creation); if (uid == 0){
///////////////////////////////////////////////////////// // User not created successfully!status =
MembershipCreateStatus.ProviderError; return null;}
//////////////////////////////////////////////////////////// // Step 3: Check if the user exists in the Membership table: Error if yes. OracleCommand command = new OracleCommand("SELECT UserId FROM PROVIDER_MEMBERSHIP WHERE USERID = :UserId", user_connection);command.Parameters.AddWithValue(
":UserId", uid); int result = Convert.ToInt32(command.ExecuteScalar()); if (result != 0){
status =
MembershipCreateStatus.DuplicateUserName; return null;}
//////////////////////////////////////////////////////////// // Step 4: Check if Email is duplicate if (RequiresUniqueEmail){
command =
new OracleCommand("SELECT u.UserId FROM PROVIDER_MEMBERSHIP m, PROVIDER_USERS u WHERE u.ApplicationId = :AppId AND m.UserId = u.UserId AND m.Email = :Email",user_connection);
command.Parameters.AddWithValue(
"AppId", appId);command.Parameters.AddWithValue(
"Email", email);result =
Convert.ToInt32(command.ExecuteScalar()); if (result != 0){
status =
MembershipCreateStatus.DuplicateEmail; return null;}
}
//////////////////////////////////////////////////////////// // Step 5: Create user in Membership table DateTime dt = RoundToSeconds(DateTime.Now);command =
new OracleCommand("INSERT INTO PROVIDER_MEMBERSHIP " + "(UserId, Email, Password,PasswordFormat, PasswordSalt,PasswordQuestion, PasswordAnswer, IsApproved,CreateDate, LastLoginDate, LastPasswordChangedDate) " + "VALUES (:UserId, :Email, :Pass,:PasswordFormat, :PasswordSalt,:PasswordQuestion, :PasswordAnswer, :IsApproved, :CDate, :LLDate, :LPCDate)",user_connection);
int pFormat = (int)_PasswordFormat;command.Parameters.AddWithValue(
":UserId", uid);command.Parameters.AddWithValue(
":Email", email);command.Parameters.AddWithValue(
":Pass", pass);command.Parameters.AddWithValue(
":PasswordFormat", pFormat);command.Parameters.AddWithValue(
":PasswordSalt", salt);command.Parameters.AddWithValue(
":PasswordQuestion", passwordQuestion);command.Parameters.AddWithValue(
":PasswordAnswer", passwordAnswer);command.Parameters.AddWithValue(
":IsApproved", isApproved);command.Parameters.AddWithValue(
":CDate", dt);command.Parameters.AddWithValue(
":LLDate", dt);command.Parameters.AddWithValue(
":LPCDate", dt); ///////////////////////////////////////////////////////// //Error while inserting row if (command.ExecuteNonQuery() != 1){
status =
MembershipCreateStatus.ProviderError; return null;}
User_Creation =
true; ///////////////////////////////////////////////////////// //store LastActivityDate for rollbackcommand =
new OracleCommand("SELECT LastActivityDate from PROVIDER_USERS " + " WHERE UserId = :UserId", user_connection);command.Parameters.AddWithValue(
"UserId", uid);dt_rollback =
Convert.ToDateTime(command.ExecuteScalar()); ///////////////////////////////////////////////////////// //update LastActivityDatecommand =
new OracleCommand("UPDATE PROVIDER_USERS " + "SET LastActivityDate = :LastActivityDate " + "WHERE UserId = :UserId", user_connection);command.Parameters.AddWithValue(
"LastActivityDate", dt);command.Parameters.AddWithValue(
"UserId", uid); //Error while updating row if (command.ExecuteNonQuery() != 1){
status =
MembershipCreateStatus.ProviderError; return null;}
User_Creation_timeupdate =
true; // // End transaction // //Transaction successfulfBeginTransCalled =
false;status =
MembershipCreateStatus.Success; ///////////////////////////////////////////////////////// //Create a new user return new MembershipUser(this.Name,username,
'1',email,
passwordQuestion,
null,isApproved,
false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue);}
catch (Exception e){
throw e;}
finally{
///////////////////////////////////////////////////////// //rollback if transaction is unsuccessful if (fBeginTransCalled){
try{
//rollback timeupdate in Provider_Users if (User_Creation_timeupdate){
OracleCommand command = new OracleCommand("UPDATE PROVIDER_USERS " + "SET LastActivityDate = :LastActivityDate " + "WHERE UserId = :UserId", user_connection);command.Parameters.AddWithValue(
"LastActivityDate", dt_rollback);command.Parameters.AddWithValue(
"UserId", uid); if (command.ExecuteNonQuery() != 1) throw new Exception("Could not update the PROVIDER_USERS table with last activity date");}
//rollback User_Create in Provider_Membership if (User_Creation){
OracleCommand command = new OracleCommand("DELETE FROM PROVIDER_MEMBERSHIP " + "WHERE UserId = :UserId", user_connection);command.Parameters.AddWithValue(
"UserId", uid); if (command.ExecuteNonQuery() != 1) throw new Exception("Could not delete the row from PROVIDER_MEMBERSHIP table");}
//rollback UserID_Creation in Provider_Users if (UserId_Creation){
OracleCommand command = new OracleCommand("DELETE FROM PROVIDER_USERS " + "WHERE UserId = :UserId", user_connection);command.Parameters.AddWithValue(
"UserId", uid); if (command.ExecuteNonQuery() != 1) throw new Exception("Could not delete the row from PROVIDER_USERS table");}
//rollback ApplicationID_Creation in Provider_Application if (ApplicationID_Creation){
OracleCommand command = new OracleCommand("DELETE FROM PROVIDER_APPLICATION " + "WHERE UserId = :UserId", user_connection);command.Parameters.AddWithValue(
"UserId", uid); if (command.ExecuteNonQuery() != 1) throw new Exception("Could not delete the row from PROVIDER_APPLICATION table");}
}
catch (Exception e){
throw e;}
}
user_connection.Close();
}
}
catch (Exception e){
throw e;}
}
diehardguy
Member
318 Points
72 Posts
Re: Custom Oracle Membership Provider
Dec 28, 2006 06:37 PM|LINK
Hi just to let you know I have figured out what was wrong. One of my methods was not implemented that I did not know that the change password method relied on. Therefore I have nearly finished the complete Membership Provider for Oracle. I have tested it and it fully integrates well with Visual Studio Web Configurator and also has a custom Roles Provider to match. All is coded in VB.NET and I will be posting it online after I have concluded documentation of it along with Oracle DDL scripts to create the tables etc. If your interested in obtaining it you can email me at damianyoung@onetel.net as I know how hard it was to find material on creating a custom class.
MCP
sumathi
Member
16 Points
12 Posts
Re: Custom Oracle Membership Provider
Dec 29, 2006 05:15 PM|LINK
Hi
I am working in ASP.NET 2.0 , C# with Oracle in backend. I am looking for C# OracleMembershipProvider. It definitely is a tremendous job. Can you please email me the code.
Thank you
RS
diehardguy
Member
318 Points
72 Posts
Re: Custom Oracle Membership Provider
Dec 29, 2006 09:39 PM|LINK
Ill be puttin the code online along with the DB schema which replicates the ASP.NET SQL db which is created. However some column names etc had to me ammened due to column name sizes in Oracle.
Ill post the link and demo next week when i tidy the code up a little.
MCP
sumathi
Member
16 Points
12 Posts
Re: Custom Oracle Membership Provider
Jan 02, 2007 02:02 PM|LINK
RS
jroland122
Member
12 Points
6 Posts
Re: Custom Oracle Membership Provider
Jan 30, 2007 07:52 PM|LINK