Last month I had written a post WLST Script to Change User Password For Multiple Domains however that worked fine for less number of domains but Baji Babu Jasti one of our subscriber asked us by commenting if we can give a new version of that automated script which can change the password of the weblogic admin account for almost 60 weblogic domains or even more without making the WLST script bigger, because in my previous script one had to copy past the whole logic again and again which would had to be equivalent to the number of domains hence that would had make the WLST script lot bigger. Thus we worked on it now we are back with the brand new Updated Version of the same WLST script to change users password for multiple domains without increasing the length of the script and wish that this script would also help our other subscribers too.
The logic behind this WLST script is the same as previous one we have just added a for loop in the ChangeAdminPassword.py and just changed few things in the property file called domainsDeatils.properties which has all the details about the domains which the password has to be changed.
1. Below is the details which domainsDeatils.properties would have
domain.name.1=Domain_8001 domain.admin.url.1=t3://localhost:8001 domain.admin.username.1=weblogic domain.admin.OLD.password.1=weblogic domain.admin.NEW.password.1=jboss_123 domain.name.2=Domain_7001 domain.admin.url.2=t3://localhost:7001 domain.admin.username.2=weblogic domain.admin.OLD.password.2=weblogic domain.admin.NEW.password.2=jboss_123
2. And below is the WLST python script ChangeAdminPassword.py which would call the above properties and will change the password.
from java.io import FileInputStream propInputStream = FileInputStream("domainsDetails.properties") configProps = Properties() configProps.load(propInputStream) for i in 1,2: domainName=configProps.get("domain.name."+ str(i)) adminUrl = configProps.get("domain.admin.url."+ str(i)) adminUser = configProps.get("domain.admin.username."+ str(i)) oldAdminPassword = configProps.get("domain.admin.OLD.password."+ str(i)) newAdminPassword = configProps.get("domain.admin.NEW.password."+ str(i)) i = i + 1 print '################################################################' print ' Chaning the Admin Password for :', domainName print '################################################################' print ' ' connect(adminUser,oldAdminPassword,adminUrl) cd('/SecurityConfiguration/'+domainName+'/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator') cmo.resetUserPassword(adminUser,newAdminPassword) print '++++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++' print '******* Congrates!!! ', domainName , ' Admin Password Changed Successfully ********' print '++++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++' print ' ' disconnect() print ' ' print '#### Connecting Using New Credentials..... ####' print ' ' connect(adminUser,newAdminPassword,adminUrl) print '#### Successfully Connected Using New Credentials !!!! ####' print ' ' disconnect()
Note:
– Make sure you keep both this files in the same folder when you are running the script or else you would have to give the path.
– Also make sure that you copy the content of the script as it.
3 . Following would be the output as soon as you run the ChangeAdminPassword.py using the below command
Command:
java weblogic.WLST ChangeAdminPassword.py
Output:
D:OracleTest AppDomain>java weblogic.WLST ChangeAdminPassword.py Initializing WebLogic Scripting Tool (WLST) ... Welcome to WebLogic Server Administration Scripting Shell Type help() for help on available commands ################################################################ Chaning the Admin Password for : Domain_8001 ################################################################ Connecting to t3://localhost:8001 with userid weblogic ... Successfully connected to Admin Server 'AdminServer' that belongs to domain 'Domain_8001'. 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. ++++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ ******* Congrates!!! Domain_8001 Admin Password Changed Successfully ******** ++++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ Disconnected from weblogic server: AdminServer #### Connecting Using New Credentials..... #### Connecting to t3://localhost:8001 with userid weblogic ... Successfully connected to Admin Server 'AdminServer' that belongs to domain 'Domain_8001'. 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. #### Successfully Connected Using New Credentials !!!! #### Disconnected from weblogic server: AdminServer ################################################################ Chaning the Admin Password for : Domain_7001 ################################################################ Connecting to t3://localhost:7001 with userid weblogic ... Successfully connected to Admin Server 'AdminServer' that belongs to domain 'Domain_7001'. 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. ++++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ ******* Congrates!!! Domain_7001 Admin Password Changed Successfully ******** ++++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ +++++++++++ Disconnected from weblogic server: AdminServer #### Connecting Using New Credentials..... #### Connecting to t3://localhost:7001 with userid weblogic ... Successfully connected to Admin Server 'AdminServer' that belongs to domain 'Domain_7001'. 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. #### Successfully Connected Using New Credentials !!!! #### Disconnected from weblogic server: AdminServer D:OracleTest AppDomain>
Advantages of this script:
- It can change any Users password , not only Admin user.
- This can be used with multiple domains.
- As it has a for loop the script does not become large or you do not have to copy paste anything other then just add the numbers in for loop.
So do let us know if this script made your life easy or not…
Regards,
Ravish Mody
December 21st, 2010 on 3:55 pm
This is a good script and very useful. Thanks Ravish for considering my comments.
Regards,
Baji.
December 22nd, 2010 on 2:59 am
we still need to manually update the boot.properties file. But script does a good job.
thanks
Sumit Kumar
January 4th, 2011 on 3:42 am
thank u so much for the script,well i have small question,im new to this ,for this statement cd(‘/SecurityConfiguration/’+domainName+’/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator’)
do i have to edit any thing.or else just keep the same statement and run it
January 4th, 2011 on 9:20 am
Hi Sudheer,
The Above script will be same until your Security Realm Name is “myrealm” ….If it is different then you will need to change the word “myrealm” in the following statement with your own security realm name:
cd(‘/SecurityConfiguration/’+domainName+’/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator’)
Example:
cd(‘/SecurityConfiguration/’+domainName+’/Realms/YOURREALM_NAME/AuthenticationProviders/DefaultAuthenticator’)
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
January 4th, 2011 on 9:35 am
thanks jay but after running this script i have to edit the boot.properties file with new password manually right?Otherwise im not able to restart admin server.
Is there any way so that boot file also can be edited automatically using this script?
January 4th, 2011 on 9:41 am
Hi Sudheer,
“boot.properties” file always we need to create on our own. WebLogic Does not provide any tools to change or create it.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
January 6th, 2011 on 2:12 am
hi jay,im new to shell scripting,if possible can u please give me a shell script to call this changeadminpassword.py and edit boot file and restart admin and managed servers
January 6th, 2011 on 7:16 pm
Hi Sudheer,
Your requirement is really very specific and not a general one, hence it would be a complex one for us to create a shell script as you are asking us to do everything in one script.
However if we get sometime would try our best to help you or guide you 🙂
Regards,
Ravish Mody
November 4th, 2011 on 5:07 am
Hi Ravish ,
How do i use the script for changing the password for any other user apart from Admin ,
What are the changes I need to do in the script ?
thanks,
Kiran
May 24th, 2018 on 2:50 pm
Hi,
I have to do a certain task in multiple domains, and say for example if one of the domain is not running, the script will stop progressing to the rest of the domains.
You have any idea how to handle this ?
Thanks.