The following is a Java
example of the IsInRole method. The method requests to know whether
the Person object named testUser has membership in the User and Group
Administrators role. The example includes code that formats and prints
the results of the request.
public void isInRole() throws Exception {
try
{
// Define a two-dimensional string array for options
final String[][] options ={{"",""}};
System.out.println("");
// Skip a line
System.out.println("<<<< Begin isInRole() >>>>" );
// Define a holder for the credential handle
StringHolder credHandle = new StringHolder();
// Define a holder for the method output
BooleanHolder inRole = new BooleanHolder();
// Get a credential handle
iSecurity.GetCredentials(testUserId, credHandle);
// Execute the method
iSecurity.IsInRole(
credHandle.value,
"ROLE_OBJNAME:" + UGAdminRole,
options,
inRole
);
// Print information about the method call and results
System.out.println();
System.out.println("<<<<<< isInRole() call parameters with results >>>>>>");
System.out.print("credHandle=" + credHandle.value + ", ");
System.out.print("roleSpecification=" + "ROLE_OBJNAME:" + UGAdminRole + ", ");
System.out.print("isInRole=" + inRole.value);
System.out.println();
// force NewLine
// Free the credentials
iSecurity.FreeCredentials(credHandle.value);
System.out.println("");
// Skip a line
System.out.println("<<<< End isInRole() >>>>" );
}
// Catch the method's exceptions.
catch (Exception e) {
System.out.println("IsInRole: GetInfo: Exceptions");
e.printStackTrace();
throw e;
}
}
Here is the output from
the request:
<<<< Begin isInRole() >>>>
<<<<<< isInRole() call parameters with results >>>>>>
credHandle=71cedcb300000001, roleSpecification=ROLE_OBJNAME:META: User
and Group Administrators Role, isInRole=true
<<<< End isInRole() >>>>