Pages

Wednesday, May 2, 2012

WLST script to reset data source password in weblogic server

WLST script to reset data source password in weblogic server


This tutorial explains the approach to reset the password of all the data sources in weblogic server. Sometime we may need to reset the password of all the data sources, the below WLST script can be used to achieve the same.

The reset through console takes more time, the below WLST script helps to reset the password quickly

WLST Script


ResetAllDataSourcePassword.py

adminIP = raw_input("Enter domain1.AdminIP:")
adminPort = raw_input("Enter domain1.AdminPort:")
adminPassword = raw_input("Enter adminPassword:")
DBPASSWORD= raw_input("Enter new DBPASSWORD:")
DOMAIN_PATH='C://Albin/SW/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain'
es = encrypt(DBPASSWORD,DOMAIN_PATH)
adminURL='t3://'+adminIP+':'+adminPort
adminUserName='weblogic'
connect(adminUserName, adminPassword, adminURL)
server='AdminServer'
cd('Servers/'+server)
target=cmo
edit()
startEdit()# SOADomain Datasource Configuration
cd('JDBCSystemResources')
allDS=cmo.getJDBCSystemResources()
for tmpDS in allDS:
    dsName=tmpDS.getName();
    print  'Changing the Password for DataSource ', dsName
    cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDriverParams/'+dsName)
    set('PasswordEncrypted',es)
save()
activate()
disconnect()


Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/ResetAllDataSourcePassword.py

Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd ResetAllDataSourcePassword.py



Now the data sources password reset to new value.






1 comment:

  1. Hi Albin,

    While executing the above script encryption error was throwing, after that modified the below line then it started working.

    syntax for encryption is:encrypt(obj, [domainDir]),
    ex: es=encrypt(DBPASSWORD,'/u01/IDMDomain/aserver/IDMDomain')

    Thank you very much

    ReplyDelete