有同事离开项目之后,需要把他们的账号删掉。
from time import localtime, strftime
def connectAdm(domainName, userName, passWord, Url):
try:
connect(userName, passWord, Url)
print '---------- Domain: ' + domainName + ' ----------'
delUsers()
disconnect()
except:
print >>fileLog, '[Exception] fail to remove users in ' + domainName
def delUsers():
serverConfig()
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')
users = ['hatA', 'hatB']
for user in users:
print 'Delete user: ', user
atnr.removeUser(user)
timeNow = strftime("%Y%m%d%H%M%S", localtime())
fileLog = open("del_user_" + timeNow + ".log", "w")
# You can remove users from multiple domains in a batch if needed
connectAdm('MedRecDomain', 'weblogic', 'weblogic1', 't3://172.16.98.4:7020')
fileLog.close()
exit()
阅读(1608) | 评论(0) | 转发(0) |