Previous Page | Next Page

Authorization (ISecurity Interface)

IsInRole

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

Parameter Type Direction Description
credHandle string in Credential handle identifying a user identity, or an empty string.
roleSpec string in A role specification in one of the following forms:

ROLE_OBJNAME : Role-Object-Name

ROLE_OBJID: Role-Object-Identifier

options string array in Two-dimensional string array for options. No options are currently defined.
inRole C out A Boolean value indicating whether the user is in the specified role.

TRUE - User is in the specified role.

FALSE - User is not in the specified role.


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:


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

Previous Page | Next Page | Top of Page