Add Bulk of users to Weblogic and add groups to user using WLST and Python Scripting (#addweblogicusers)

Create user:

The syntax for creating the user is as below, but the command for creating user should be passed in a python script from WLST.

Invoke the wlst and connect to Domain in which the users need to be created. And execute the python script called “createuser.py) from wlst to create the users.

$FMW_HOME/wlserver_10.3/common/bin/wlst.sh

connect(‘weblogic’,xxxxxxx’,’t3://<AdminConsoleURL>:7001′)

execfile(‘createuser.py’)

The commands in createuser.py is as below,

===

createuser.py:

serverConfig()

print ‘lookup DefaultAuthenticator’

password =‘xxxxxx’

atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider(“DefaultAuthenticator”)

atnr.createUser(‘user1′,’oracle123′,’Admin_Domain’)

atnr.createUser(‘user2′,’oracle123′,’Admin_Domain’)

atnr.createUser(‘userN’,’oracle123′,’Admin_Domain’)

print “Created user successfully”

===

Adding group to users:

Invoke the wlst and connect to Domain in which the users need to be created. And execute the python script called “addusers_togroup.py) from wlst to add groups to user.

$FMW_HOME/wlserver_10.3/common/bin/wlst.sh

connect(‘weblogic’,xxxxxxx’,’t3:<AdminConsole_URL>:7001′) execfile(‘addusers_togroup.py’)

The commands in addusers_togroup.py is as below,

===

addusers_togroup.py:

serverConfig()

print ‘lookup DefaultAuthenticator’

password = ‘xxxxxxxxx’

atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider(“DefaultAuthenticator”)

group = ‘testing_Admin_group’

atnr.addMemberToGroup(group,user1)

atnr.addMemberToGroup(group,user2)

atnr.addMemberToGroup(group,user3)

atnr.addMemberToGroup(group,userN)

===

This completes creating bulk users from WLST and add groups to user using python script.

Advertisements
This entry was posted in WebLogic. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s