如果要在自己管理的上百个domain里面创建多个用户,手工来做实在是太痛苦了,幸好我们可以用WLST脚本来搞定。
from time import localtime, strftime
def connectAdm(domainName, userName, passWord, Url):
try:
connect(userName, passWord, Url)
print '---------- Domain: ' + domainName + ' ----------'
addUsers()
disconnect()
except:
print >>fileLog, '[Exception] fail to add users in ' + domainName
def addUsers():
serverConfig()
password = 'weblogic1'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')
group = 'Administrators'
users = ['hatA', 'hatB']
descs = ['HAT Shell', 'HAT Middleware']
n = 0
for user in users:
desc = descs[n]
n += 1
print 'Add user: ', user
atnr.createUser(user, password, desc)
atnr.addMemberToGroup(group, user)
timeNow = strftime("%Y%m%d%H%M%S", localtime())
fileLog = open("add_user_" + timeNow + ".log", "w")
# You can add users into multiple domains in a batch if needed
connectAdm('MedRecDomain', 'weblogic', 'weblogic1', 't3://172.16.98.4:7020')
fileLog.close()
exit()
阅读(2457) | 评论(0) | 转发(0) |