Share via


RunAsPermission Class

Definition

The RunAsPermssion class controls the execution of code in the security context of another user.

public ref class RunAsPermission : Microsoft::Dynamics::Ax::Xpp::CodeAccessPermission
[Microsoft.Dynamics.Ax.Xpp.KernelClass]
public class RunAsPermission : Microsoft.Dynamics.Ax.Xpp.CodeAccessPermission
[<Microsoft.Dynamics.Ax.Xpp.KernelClass>]
type RunAsPermission = class
    inherit CodeAccessPermission
Public Class RunAsPermission
Inherits CodeAccessPermission
Inheritance
Microsoft.Dynamics.AX.KernelInterop.ProxyBase
RunAsPermission
Attributes

Remarks

You must call the assert method on the same tier, usually the server tier, that the corresponding CodeAccessPermission.demand method is called on before the protected API is executed. Call a method on the server tier from one of the following: The RunAsPermission class is designed to check permissions for the runAs function. For a list of all APIs protected by permissions, see Secured APIs.

A server static method, or a class instance method that is set to run on the server by using the RunOn class property.

The following code example shows a new instance of the RunAsPermission class. The assert method is called to declare that the code can then call the runAs function to run the EventJobDueDate.:runDueDateEventsForUser method in the security context of another user.

server static void main(Args args) 
{ 
    RunAsPermission _perm; 
    UserId          _runAsUser; 
    SysUserInfo     _userInfo; 
    _userInfo = SysUserInfo::find(); 
    _runAsUser = _userInfo.Id; 
    _perm = new RunAsPermission(_runAsUser); 
    _perm.assert(); 
    // Invoke the protected API. 
    RunAs(_runAsUser, classnum(EventJobDueDate), "runDueDateEventsForUser"); 
    // Optionally, call revertAssert() to limit the scope of assert. 
    CodeAccessPermission::revertAssert(); 
}

Constructors

RunAsPermission()
RunAsPermission(IntPtr)
RunAsPermission(String)

Fields

__k_RunAsPermissionId
kernelClass (Inherited from XppObjectBase)

Methods

__shouldCallNew(Type)
addXppProxyReference(Type, Object) (Inherited from XppObjectBase)
assert()

Declares that the calling code can invoke an API that is protected by a permission.

(Inherited from CodeAccessPermission)
Call(String, Object[], Type[], Object[]) (Inherited from XppObjectBase)
cancelTimeOut(Int32) (Inherited from XppObjectBase)
Copy()

Creates and returns a copy of a permission class object.

createKernelClass(Object[], Type[], Object[]) (Inherited from XppObjectBase)
demand()

Checks the call stack to determine whether the permission that is required to invoke an API has been granted to the calling code.

(Inherited from CodeAccessPermission)
equal(XppObjectBase) (Inherited from XppObjectBase)
finalize() (Inherited from XppObjectBase)
GetIntPtr() (Inherited from XppObjectBase)
GetKernelInstanceUniqueId() (Inherited from XppObjectBase)
getTimeOutTimerHandle() (Inherited from XppObjectBase)
getXppProxyReference(Type) (Inherited from XppObjectBase)
handle()
IsManagedValid() (Inherited from XppObjectBase)
Issubsetof(CodeAccessPermission)

Determines whether a current permission is a subset of the specified permission when overridden by a derived class.

kernelhandle()
KernelInstanceDisposed() (Inherited from XppObjectBase)
MakeReflectionCall(String, Object[]) (Inherited from XppObjectBase)
newmethod()

Initializes a new instance of the CodeAccessPermission class.

(Inherited from CodeAccessPermission)
newmethod(String)

Initializes a new instance of the CodeAccessPermission class.

notify() (Inherited from XppObjectBase)
notifyAll() (Inherited from XppObjectBase)
objectOnServer()
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32, Boolean)
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32)
Obsolete.
(Inherited from XppObjectBase)
usageCount() (Inherited from XppObjectBase)
VerifyKernelClass() (Inherited from XppObjectBase)
wait() (Inherited from XppObjectBase)
Xml() (Inherited from XppObjectBase)
Xml(Int32) (Inherited from XppObjectBase)

Applies to