IsImpersonating PowerScript function
Description
Queries whether a COM object running on COM+ is impersonating
the client.
Controls
TransactionServer objects
Syntax
|
1 |
<span>transactionserver</span>.<span>IsImpersonating</span> ( <span> </span>) |
|
Argument |
Description |
|---|---|
|
transactionserver |
Reference to the TransactionServer service |
Return Values
Boolean. Returns true if
the component is impersonating the client and false if it
is not.
Usage
COM objects running on COM+ can use the ImpersonateClient function
to run in the client’s security context so that the server
process has access to the same resources as the client. Use IsImpersonating to
determine whether the ImpersonateClient function
has been called without a matching call to RevertToSelf.
Examples
The following example creates an instance of the
TransactionServer service and checks whether the COM object is currently
running on the client’s security context. If it is not,
it impersonates the client, performs some processing using the client’s
security context, then reverts to the object’s security
context:
|
1 |
TransactionServer txninfo_test |
|
1 |
integer li_rc |
|
1 |
|
1 |
li_rc = GetContextService( "TransactionServer", & |
|
1 |
txninfo_test ) |
|
1 |
IF NOT txninfo_test.<span>IsImpersonating</span>() THEN |
|
1 |
txninfo_test.ImpersonateClient() |
|
1 |
END IF |
|
1 |
// continue processing as client |
|
1 |
txninfo_test.RevertToSelf() |