Saturday, February 2, 2013

Security and dealing with cursors in WLST

username = 'Pierluigi'
password = 'weblogic1'
url='t3://myserver.acme.com:7001'
connect(username,password,url)
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')


at this point I want to see all the groups to which a given user 'chennapa' belongs:

atnr.listMemberGroups('chennapa')

'Cursor_181'

what whall I do with this bloody 'Cursor_181' ???
As very well explained here, I need some special instruction to iterate over the cursor:

the instructions are haveCurrent, advance and close

cursor=atnr.listMemberGroups('chennapa')
while atnr.haveCurrent(cursor):
    print atnr.getCurrentName(cursor)
    atnr.advance(cursor)

atnr.close(cursor)

 viewMBean(atnr)
Attribute Names and Values
--------------------------
MaxGroupHierarchiesInCache                   100
KeepAliveEnabled                             false
SupportedImportFormats                       java.lang.String[DefaultAtn]
SupportedImportConstraints                   java.lang.String[]
Description                                  WebLogic Authentication Provider
ControlFlag                                  SUFFICIENT
GroupHierarchyCacheTTL                       60
PropagateCauseForLoginException              false
PasswordDigestEnabled                        false
MaxGroupMembershipSearchLevel                0
EnableGroupMembershipLookupHierarchyCaching  true
SupportedUserAttributeNames                  java.lang.String[displayname, employeenumber, employeetype, givenname, homephone, mail, title, preferredlanguage, departmentnumber, facsimiletelephonenumber, mobile, pager, telephonenumber, postaladdress, street, l, st, postofficebox, c, homepostaladdress]
SupportedExportFormats                       java.lang.String[DefaultAtn]
Name                                         DefaultAuthenticator
UseRetrievedUserNameAsPrincipal              true
SupportedExportConstraints                   java.lang.String[users, groups, passwords]
ProviderClassName                            weblogic.security.providers.authentication.DefaultAuthenticationProviderImpl
Realm                                        Security:Name=myrealm
GroupMembershipSearching                     unlimited
Version                                      1.0
MinimumPasswordLength                        8
------------------------
Operations on this MBean
------------------------
setGroupDescription
changeUserPassword
setUserDescription
listMemberGroups
removeMemberFromGroup
groupExists
getGroupDescription
advance
getUserDescription
haveCurrent
listGroupMembers
unSet
getSupportedUserAttributeType
getUserAttributeValue
wls_getDisplayName
userExists
close
isSet
createGroup
listGroups
resetUserPassword
createUser
removeUser
addMemberToGroup
listAllUsersInGroup
setUserAttributeValue
importData
isMember
removeGroup
listUsers
exportData
isUserAttributeNameSupported
getCurrentName



No comments: