locked
Changing Oracle user password using ODP.NET in WinForm? RRS feed

  • Question

  • User-1949910660 posted

    Hi, I am trying to create a form which allowed user to change their password. Logins  (username/pwd) will be managed via Oracle ... but I am not sure how to do that. Can anyone help?

    Tuesday, August 23, 2011 12:41 PM

All replies

  • User269602965 posted

    You can call Oracle Procedures from .NET

     

    .NET
    
    get your oracle connection string OraConn (various methods depending on your environment)
    
    Dim OraCmd As New OracleCommand()
            OraCmd.Connection = OraConn
            OraCmd.CommandText = "{yourschemaName}.proc_change_password"
            OraCmd.CommandType = CommandType.StoredProcedure
            OraCmd.ExecuteNonQuery()
     OraConn.Close()
    
    Oracle PL/SQL procedure
    
    CREATE OR REPLACE PROCEDURE proc_change_password
    AS
    begin
      execute immediate alter user {user_name} identified by {new_password};
    end;
    
    WIth parameters, you can modify the PL/SQL to pass into the procedure the schema name (user name) and the password from .NET
    
    Tuesday, August 23, 2011 4:23 PM
  • User-2128037440 posted
    create or replace
    PROCEDURE CHANGE_USER_PASSWORD(
        USER_NAME_IN    IN VARCHAR2 ,
        NEW_PASSWORD_IN IN VARCHAR2 )
    AS
    BEGIN
      EXECUTE IMMEDIATE 'ALTER USER '|| USER_NAME_IN ||' IDENTIFIED BY '|| NEW_PASSWORD_IN;
      COMMIT;
    END CHANGE_USER_PASSWORD;
    Above is a oracle procedure for change user password, Here USER_NAME_IN is user logon name and NEW_PASSWORD_IN is new password which you wan to change.
    If you want to test this procedure, please run use below code on sql plus.
    BEGIN
    CHANGE_USER_PASSWORD('HR','xyz');
    END;
    Monday, November 28, 2011 6:57 AM