Here is an example of the user creation phyton script.
serverConfig()
print 'lookup DefaultAuthenticator'
password = 'weblogic1'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')
print 'create group App-MHS-Users'
group = 'App-MHS-Users'
atnr.createGroup(group,group)
users = ['user1','user2']
for user in users:
print 'create user: ',user
atnr.createUser(user,password,user)
atnr.addMemberToGroup(group,user)
print 'create group App-MHS-Admin'
group = 'App-MHS-Admin'
atnr.createGroup(group,group)
users = ['admin1','admin2']
for user in users:
print 'create user: ',user
atnr.createUser(user,password,user)
atnr.addMemberToGroup(group,user)
print 'create group App-MHS-SB'
group = 'App-MHS-SB'
atnr.createGroup(group,group)
users = ['sbuser1','sbuser2']
for user in users:
print 'create user: ',user
atnr.createUser(user,password,user)
atnr.addMemberToGroup(group,user)
To run this script we need a Weblogic environment ( can be remote ) and start wlst.cmd or wlst.sh
Go to the C:\Oracle\jdevstudio111120\wlserver_10.3\common\bin folder and start wlst.cmd
connect('weblogic','weblogic1','t3://server.domainname:7001')
execfile('/oracle/wls_scripts/createDefaultUserAndGroup.py')
disconnect()
exit()
that's all.
This works great. Thanks a lot.
ReplyDeleteCómo puedo capturar el error cuando el grupo ya existe?
ReplyDeleteIntenté usar un try exception, pero no me funcionó.
thank you!
ReplyDeleteThanks. This helped me create users in bulk.
ReplyDeletethanks m8, works like a charm!
ReplyDeleteHi Edwin,
ReplyDeleteI have the user creation script created. I have saved it in my C drive. How do I execute that. Do I have to place it in any path inside the domain. I am not sure how to execute the same.
I saw that in ur post u have given the below path:
execfile('/oracle/wls_scripts/createDefaultUserAndGroup.py') -- is this the local directory path? please suggest.
this is my userCreation.py
serverConfig() print ‘lookup DefaultAuthenticator’ atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider(‘DefaultAuthenticator’) print ‘create group ServiceUserGroup’ group = ‘ServiceUserGroup’ atnr.createGroup(group,group) print ‘create user: ‘,’chaithra’ atnr.createUser(‘chaithra’,’cRU2rEQa’,’chaithra’) atnr.addMemberToGroup(‘ServiceUserGroup’,’chaithra’)
print ‘User created'
Thanks in advance.
Hi,
Deleteyou need to start wlst.sh , connect() to your adminserver and start execfile('aaa.py')
Is there any way to create user and group offline, I mean without running server.
ReplyDelete