IObjectContext.IsCallerInRole, IObjectContext.IsSecurityEnabled Methods Example

import com.ms.mtx.*;

IObjectContext objContext = null;

objContext = MTx.GetObjectContext();

// Find out if Security is enabled.
if (objContext.IsSecurityEnabled()) {
    //Then find out if the caller is in the right role.
    if (!objContext.IsCallerInRole("Manager")) {
        // If not, do something appropriate here.
    }
}
else {
    // If security's not enabled, do something 
    // appropriate here.
}