【问题标题】:How can I list user and user's roles in weblogic by wlst?如何通过 wlst 在 weblogic 中列出用户和用户的角色?
【发布时间】:2020-07-25 22:27:27
【问题描述】:

有谁知道如何在 java ( wlst ) 中列出所有 weblogic 用户和用户角色列表?

最好的问候。

【问题讨论】:

    标签: java weblogic wlst


    【解决方案1】:

    用户列表:

    from weblogic.management.security.authentication import UserReaderMBean
    from weblogic.management.security.authentication import GroupReaderMBean
    realm=cmo.getSecurityConfiguration().getDefaultRealm()
    atns = realm.getAuthenticationProviders()
    for i in atns:
        if isinstance(i,UserReaderMBean):
            userReader = i
            cursor = i.listUsers("*",0)
            print 'Users in realm '+realm.getName()+' are: '
            while userReader.haveCurrent(cursor):
                print userReader.getCurrentName(cursor)
                userReader.advance(cursor)
            userReader.close(cursor)
    for i in atns:
        if isinstance(i,GroupReaderMBean):
            groupReader = i
            cursor = i.listGroups("*",0)
            print 'Groups in realm are: '
            while groupReader.haveCurrent(cursor):
                print groupReader.getCurrentName(cursor)
                groupReader.advance(cursor)
            groupReader.close(cursor)
    

    角色列表:

    rm=cmo.getSecurityConfiguration().getDefaultRealm().lookupRoleMapper("XACMLRoleMapper")
    print rm.getProviderClassName()
    print rm.getName()
    
    cursor = rm.listAllRoles(1000)
    print cursor
    
    userReader = rm 
    while userReader.haveCurrent(cursor):
        usrrd = userReader.getCurrentProperties(cursor)
        print usrrd.get('RoleName') 
        #print usrrd
        print "\t",usrrd.get('Expression')
    
        userReader.advance(cursor)
    userReader.close(cursor)
    

    【讨论】:

    • 非常感谢您的回答。但我想要他们两个。例如; Emmanuel Collin-管理员
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-23
    • 2020-07-27
    • 2018-03-08
    相关资源
    最近更新 更多