刚进项目的时候,同事再100个domain里面给我创建了用户,但是默认密码不好记,于是我要批量修改一下密码。
from time import localtime, strftime
def connectAdm(domainName, userName, passWord, Url):
try:
connect(userName, passWord, Url)
print '---------- Domain: ' + domainName + ' ----------'
changePass()
disconnect()
except:
print >>fileLog, '[Exception] fail to change password in ' + domainName
def changePass():
serverConfig()
passwordOld = 'weblogic1'
passwordNew = 'weblogic2'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider("DefaultAuthenticator")
users = ['hatA', 'hatB']
for user in users:
print 'Change password for user: ', user
atnr.changeUserPassword(user, passwordOld, passwordNew)
timeNow = strftime("%Y%m%d%H%M%S", localtime())
fileLog = open("change_pass_" + timeNow + ".log", "w")
# You can change password in multiple domains in a batch if needed
connectAdm('MedRecDomain', 'weblogic', 'weblogic1', 't3://172.16.98.4:7020')
fileLog.close()
exit()
阅读(3217) | 评论(0) | 转发(0) |