0 Replies Latest reply: Mar 8, 2011 5:44 PM by yhyhyh RSS

    Error ORA-06502 when calling Membership.GetUser() or CreateUser()

    yhyhyh
      Problem:
      I’m using VS2010, .NET 4.0, ODP.NET (ODAC 11.2.0.1.2), Oracle 9i (9.2.0.6.0).

      I’m trying to use the Oracle Providers to create users and roles. Somehow, I was able to create one user, and one role, however, I now get an Oracle error (“ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1”) when I call GetUser(), or CreateUser(),Roles.RoleExists(), or Roles.CreateRole(), or use the wizards, e.g. CreateUserWizard. However, Membership.GetAllUsers() works!

      For example the traceback when calling GetUser():
      at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
      at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
      at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
      at Oracle.Web.Security.OracleMembershipProvider.GetUser(String username, Boolean userIsOnline)
      at System.Web.Security.Membership.GetUser(String username, Boolean userIsOnline)
      at xxxx.Create_Users_and_Roles.Page_Load(Object sender, EventArgs e) in C:\xxxxxxxx\Create_Users_and_Roles.aspx.cs:line 96
      at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
      at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
      at System.Web.UI.Control.OnLoad(EventArgs e)
      at System.Web.UI.Control.LoadRecursive()
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


      In Web.config:

      <membership defaultProvider="MyOracleMembershipProvider">
      <providers>
      <add name="MyOracleMembershipProvider"
      type="Oracle.Web.Security.OracleMembershipProvider,
      Oracle.Web, Version=4.112.1.2, Culture=neutral,
      PublicKeyToken=89b483f429c47342"
      connectionStringName="ConnectionString"
      applicationName="XXXXX"
      enablePasswordRetrieval="false"
      enablePasswordReset="true"
      requiresQuestionAndAnswer="false"
      requiresUniqueEmail="true"
      passwordFormat="Hashed"
      maxInvalidPasswordAttempts="4"
      minRequiredPasswordLength="9"
      passwordAttemptWindow="8" />
      </providers>
      </membership>

      <roleManager enabled="true" defaultProvider="MyOracleRoleProvider">
      <providers>
      <add name="MyOracleRoleProvider"
      type="Oracle.Web.Security.OracleRoleProvider,
      Oracle.Web, Version=4.112.1.2, Culture=neutral,
      PublicKeyToken=89b483f429c47342"
      connectionStringName="ConnectionString"
      applicationName=" XXXXX "/>
      </providers>
      </roleManager>

      code snippet:
      using Oracle.Web.Security;
      using System.Web.Security;

      namespace Xxxx
      {
      public partial class Create_Users_and_Roles : System.Web.UI.Page
      {

      protected void Page_Load(object sender, EventArgs e)
      {
      MembershipUser newUser;
      MembershipCreateStatus status;

      lblMessage.Text = "";

      // Calling GetAllUsers() works:
      //MembershipUserCollection memCollection = Membership.GetAllUsers();


      status = new MembershipCreateStatus();
      newUser = null;

      // ==== Try to create user: tstuser ====
      try
      {
      newUser = Membership.GetUser("tstuser");// Does user exist?
      }
      catch (OracleException ex)
      {
      lblMessage.Text += ex.Message; // get error here: "ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1"
      }
      catch (Exception ex)
      {
      lblMessage.Text += ex.Message;
      }

      if (newUser == null) // If user does not exist, then create user
      {
      try
      {
      newUser = Membership.CreateUser("tstuser", "XXXXX", "tstuser@abc.def", "xxx", "xxx", true, out status);
      }
      catch (MembershipCreateUserException eArgs)
      {
      lblMessage.Text += GetErrorMessage(eArgs.StatusCode);
      }

      catch (OracleException ex)
      {
      lblMessage.Text += ex.Message;
      }

      catch (HttpException eArgs)
      {
      lblMessage.Text += eArgs.Message;
      }
      }
      else
      {
      lblMessage.Text += "User " + newUser.UserName + " already exists";
      }


      // === Create Role myRole1: ===
      if (!Roles.RoleExists("myRole1"))
      {
      Roles.CreateRole("myRole1");
      }