2012/12/03

OBIEE 11g - Adding Users using WLST script

Adding Users - using WLST script


There might be situations where we may have to create new users to OBIEE 11g environment.

If is a small list it can be achieved from FMW Console and we all know that how painful it will be if we have a long list of users to be created.

This situation might arise - if the OBIEE 11g security is configured to use the default WLS LDAP OR if your corporate LDAP has missing users.

Rather than creating the users from FMW console, a WLST script can be used to achieve the same and in much easier way.

The below is the script -

There are two parts to this script - a shell part and jython part which is called from the shell script.



Shell Script -



#############################################
# Script to create users in to Weblogic domain #################################################
# Mahesh - 11/08/2012 - Createad # Usage - Called from Command Prompt
# Parameter 1 - Weblogic Password
# Parameter 2 - FMW EM URL
# Parameter 3 - User ID for which the groups to be listed
#############################################

touch '/xx/oracle/data/create_ea_users_env.log' cd $MW_HOME/wlserver_10.3/server/bin . ./setWLSEnv.sh java -Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.TrustKeyStore=DemoTrust weblogic.WLST /app/oracle/data/create_ea_users_env.py $1 $2 $3




Jython Script -





##############################################
# Script to create users in to Weblogic domain
##################################################
# Mahesh - 11/08/2012 - Createad
# Usage - Called from the script create_ea_users_pta2.sh
#####################################################
redirect('/app/oracle/data/create_ea_users_env.log','false')


import sys
import datetime


sys.stdout = open('/app/oracle/data/create_ea_users_pta2.log','w+')


#
# declare env variables
#

adminUser = 'weblogic'
adminPassword = sys.argv[1]
adminURL = sys.argv[2]
userID = sys.argv[3]

now = datetime.datetime.now()
print 'Current date and time is :' print str(now)

print 'Admin User:',adminUser
print 'Admin Password:',adminPassword
print 'Admin URL:',adminURL

#
# connect to weblogic admin server
#

connect(adminUser, adminPassword, adminURL)

serverConfig()

atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider("DefaultAuthenticator")

description = 'Adhoc User'

password = 'Password1'

print 'creating users '

users = ['A523887','User1','User3','bobharris','tomhill']

for user in users:

print 'create user: ', user

atnr.createUser(user, password, description)

print 'End of Script'

1 comment:

  1. Hi Mahesh,

    Nice post... But small requirement. I have a file consists of list of users. I have to pick the file and create users..That means in the place of "users = ['A523887','User1','User3','bobharris','tomhill']" can i specify the file path?? will that work?? any alternative??

    Thanks

    ReplyDelete

File Handling with Python

This little utility is for copying files from source to target directories.  On the way it checks whether a directory exists in the target, ...