Authorization (ISecurity Interface) |
Returns the TRUE value when the user specified in CREDHANDLE is in a role.
Category: Generalized authorization methods
Interface version: ISecurity 1.1
Syntax |
IsInRole(credHandle,roleSpec,options,inRole);
Parameters |
Details |
The IsInRole method determines whether a user is in the specified role. The role is identified by the value in the Role object's Name= attribute or by its metadata object identifier.
This method is most appropriate for static role implementations.
Exceptions Thrown |
The SAS Open Metadata Interface explicitly returns the following exceptions for the IsInRole method:
NotTrustedUser
InvalidCredHandle
InvalidResourceSpec
Examples |
The following is a Java example of the IsInRole method. The method requests to know if 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() >>>>
Related Methods |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.