How to Change Oracle Weblogic Server User Password Using WLST

1. Setting environment variable
    a. go to directory $WLS_HOME/wlserver_10.3/server/bin
    b. source file setWLSEnv.sh  as command: . setWLSEnv.sh .

2. Create a domain which name is test1032,
3. Weblogic admin user name is weblogic, password is weblogic1.
4. Create test user, which name is test and password is weblogic1.


Instruction 
$java weblogic.WLST changepw.py <Domain Name> <Admin URI> <Admin user> <Admin password> <user name> <user password>

<Domain Name> : the domain name which need to change user password. e.g. test1032
<Admin URI>   : weblogic server adminstration URL, e.g. t3://localhost:7001
<Admin user>  : weblogic admin user, e.g. weblogic
<Admin password>  : admin user password, e.g. weblogic1
<user name>       : the user who need to change password. e.g. test
<user password>   : new user password. .e.g welcome1 
 1. create file named changepw.py which contents as below:

if len(sys.argv) != 7:
print 'Usage: java weblogic.WLST changepw.py <Domain Name> <Admin URI> <Admin user> <Admin password> <user name> <user password> '
sys.exit(1)

DomainName = sys.argv[1]
ADMINUrl = sys.argv[2]
ADMINuser = sys.argv[3]
ADMINPwd = sys.argv[4]
UserToChange = sys.argv[5]
NewUserPassword=sys.argv[6]

print "DomainName: %s" % (DomainName)
print "ADMINUrl: %s" % (ADMINUrl)
print "ADMINuser: %s" % (ADMINuser)
print "AdminPassword: %s" % (ADMINPwd)
print "UserToChange: %s" % (UserToChange)
print "NewUserPassword: %s" % (NewUserPassword)


print ' ---- Connecting to domain with user: '+ADMINuser+' ------- '
print ' '
connect(ADMINuser,ADMINPwd,ADMINUrl)
cd('/SecurityConfiguration/'+DomainName+'/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator')
print 'Changing password for user: '+UserToChange
cmo.resetUserPassword(UserToChange,NewUserPassword)

print ' ---- Password for User: '+UserToChange+' changed Successfully --- '
print ' '
disconnect()
print ' '

disconnect()

2. The command to run above script, e.g. change password from weblogic1 to weblogic
java weblogic.WLST changepw.py test1032 t3://localhost:7001 weblogic weblogic1 test welcome1

Sample Output
[zsy@ofmpc1 bin]$ java weblogic.WLST changepw.py test1032 t3://localhost:7001 weblogic weblogic1 test welcome1

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

DomainName: test1032
ADMINUrl: t3://localhost:7001
ADMINuser: weblogic
AdminPassword: weblogic1
UserToChange: test
NewUserPassword: welcome1
---- Connecting to domain with user: weblogic -------

Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'test1032'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

Changing password for user: test
---- Password for User: test changed Successfully ---

Disconnected from weblogic server: AdminServer


You will need to be connected to a running server to execute this command

Comments

Popular posts from this blog

Interview question for File and FTP Adapter

What is boot.properties file and how to create

SSL Exceptions in Admin Server and Node Manager.