尝试自动化用户和群组映射到WAS中的应用程序是我正在尝试验证这是否该怎么做的脚本,因为我不太了解WAS
导入sys
filename=""
fileread = open(filename, 'r')
filelines = fileread.readlines()
for row in filelines:
column=row.strip().split(';')
user_name=column[0]
print user_name
pass_word=column[1]
first=column[2]
last=column[3]
AdminTask.createUser(['-uid',user_name, '-password', pass_word, '-confirmPassword', pass_word, '-cn', first, '-sn', last ])
AdminTask.mapUsersToAdminRole(['-roleName','Administrator','-userids',user_name])
AdminConfig.save()
print 'Userid creation completed for', user_name
AdminApp.install('myapp.ear', '[-MapRolesToUsers [["All Role" No Yes "" ""]
["Every Role" Yes No "" ""] [DenyAllRole No No user1 group1]]]')
agmBean = AdminControl.queryNames('type=AuthorizationGroupManager,process=dmgr,*')
AdminControl.invoke(agmBean, 'refreshAll')
fileread.close()
答案 0 :(得分:0)
根据您之前的问题判断,我假设您已设置LDAP服务器。如果要将用户从LDAP服务器映射到管理员角色,则无需创建新用户。像这个命令之类的东西会将user1从LDAP映射到admin角色:
AdminTask.mapUsersToAdminRole('[-accessids [user:defaultWIMFileBasedRealm/cn=user1,ou=users,dc=yourco,dc=com ] -userids [user1 ] -roleName administrator]')
域名可以在CELL_DIR / wim / config下的wimconfig.xml中找到; defaultWIMFileBasedRealm是默认值。我建议手动运行该命令,当你完成所有工作后,编写脚本。