Wednesday, June 19, 2013

Adding Test Users to Weblogics embedded LDAP

You may want to add Users in the DefaultAuthenticator that comes OOTB when Weblogic is installed for various reasons ( Providing access to Test teams or creating multiple users for performance testing etc)

Here is a simple method of creating those users

Navigate to the folder

E:\Oracle\Middleware\wlserver_10.3\server\bin

create a file with any name example addMyTestUsers.py

edit the file and add the following script to it and save ( note the script also adds the created users to a group someGroup )

****************************
connect ("admin","password","localhost:7001")
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider("DefaultAuthenticator")
users=['test1','test2','test3','test4','test5']
groups=['someGroup']
for user in users:
try:
atnr.createUser(user,'password','TestUser')
print user,': created'
except Exception, e:
print user,': exist'
for group in groups:
for user in users:
try:
atnr.addMemberToGroup(group,user)
print user,': add to group'
except Exception, e:
print user,': exist in group'

*******************************


Open a command prompt

Cd to E:\Oracle\Middleware\wlserver_10.3\server\bin
run the file setWLSEnv.cmd to set environment variables

then run the command

java weblogic.WLST addMyTestUsers.py

The script will add users that done already exist and associate them to a security group or multiple groups as per values provided

Add users to line: users=[‘ username here‘, …]
Add group names to line: groups =[‘group name here’,…]


2 comments:

  1. really good piece of information, I had come to know about your site from my friend shubodh, kolkatta,i have read atleast nine posts of yours by now, and let me tell you, your site gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a lot once again, Regards, obiee training institutes in hyderebad

    ReplyDelete
  2. It is very good Trip for Obiee Users thanks for the InfoQlikview Training in Hyderabad

    ReplyDelete