WLST Python 스크립트는 셸 스크립트의 변수를 받아들일 수 없습니다.

WLST Python 스크립트는 셸 스크립트의 변수를 받아들일 수 없습니다.

사용자가 특정 그룹에 속해 있는지 확인하기 위해 WLST 스크립트를 만들었습니다. 쉘 스크립트는 사용자 및 그룹 이름에 대한 입력을 읽고 이를 Python 스크립트로 보냅니다. 다음은 Python 스크립트입니다.

d_user=sys.argv[1]
print 'User is ' +d_user
d_group=sys.argv[2]
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"

출력은 다음과 같습니다.

./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.

불평하지 않는다그룹을 찾을 수 없습니다. Python 스크립트는 d_user처음에 &에 대한 변수를 허용할 수 있었지만 d_group일단 Weblogic 도메인에 연결되면 d_user&로 제공된 값을 인식하지 못하고 d_group대신 변수 이름을 실제 입력으로 사용했습니다.

Checking if 'd_user' is a member of the group 'd_group'

d_user&를 실제 사용자 및 그룹으로 바꾸면 스크립트가 제대로 작동합니다.d_group

내가 무엇을 간과하고 있는지 알 수 없습니다.

답변1

따옴표

atnr.isMember('d_group','d_user',true)

문제는 다음과 같습니다

atnr.isMember(d_group,d_user,true)

관련 정보