Sample Header Ad - 728x90

WLST Python script unable to accept the variable from Shell Script

-1 votes
1 answer
1023 views
I created a WLST Script that checks if a user belongs to a particular group. The shell script reads input for the user and group name & sends to it to the python script. This is the python script:
d_user=sys.argv
print 'User is ' +d_user
d_group=sys.argv
print 'Group is ' +d_group

connect(userConfigFile='WebLogicConfig.properties',userKeyFile='WebLogicKey.properties',url='t3://wl-test.com:80')
    
realmName=cmo.getSecurityConfiguration().getDefaultRealm()
authProvider = realmName.getAuthenticationProviders()

from weblogic.management.security.authentication import GroupEditorMBean
print "Checking if 'd_user' is a member of the group 'd_group' ... "
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider("DefaultAuthenticator")
if atnr.isMember('d_group','d_user',true) == 0:
  print "+d_user is not member of +d_group"
else:
  print "+d_user is a member of +d_group"
This is the output: ./UserGroupCheck.sh Enter the user name you want to check : weblogic Enter the group name you want to check for weblogic : Administrators CLASSPATH=... PATH=... Your environment has been set. Initializing WebLogic Scripting Tool (WLST) ... Welcome to WebLogic Server Administration Scripting Shell Type help() for help on available commands User is weblogic Group is Administrators Connecting to t3://wl-test.com:80 with userid weblogic ... Successfully connected to Admin Server.. ... Checking if 'd_user' is a member of the group 'd_group' ... Problem invoking WLST - Traceback (innermost last): File "UserGroupCheck.py", line 20, in ? weblogic.management.utils.NotFoundException: [Security:090259]Group d_group can not be found. at weblogic.utils.StackTraceDisabled.unknownMethod() weblogic.management.utils.NotFoundException: weblogic.management.utils.NotFoundException: [Security:090259]Group d_group can not be found. It fails complaining that the **group is not found**. The python script is able to accept the variables for d_user and d_group initially, however once it is connected to the Weblogic domain, it is unable to recognize the values given for d_user & d_group and instead takes the variable names as the actual input.
Checking if 'd_user' is a member of the group 'd_group'
The script works fine, if I replace the d_user & d_group with actual user & groups. I am unable to figure out what I overlooked.
Asked by Tony Jose (7 rep)
Apr 18, 2020, 06:38 PM
Last activity: Apr 23, 2020, 08:01 AM