ImpersonateClient PowerScript function
Description
Allows a COM object running on COM+ to take on the
security attributes of the client for the duration of a call.
Controls
TransactionServer objects
Syntax
|
1 |
<span>transactionserver</span>.<span>ImpersonateClient</span> ( <span> </span>) |
|
Argument |
Description |
|---|---|
|
transactionserver |
Reference to the TransactionServer service |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs.
Usage
ImpersonateClient allows a COM object to
run in the client’s security context for the duration of
a call. Running in the client’s security context gives
the server process access to the same resources as the client. This
can either restrict or expand the server’s access to resources.
For example, if the client does not have update rights to a database
but the server does, impersonating the client before accessing the
database prevents the client from updating the database.
After completing the processing that requires the client’s
security context, call RevertToSelf to revert
to the server’s security context.
Examples
This example creates an instance of the transaction
server context object and impersonates the client to perform some
processing:
|
1 |
TransactionServer txninfo_test |
|
1 |
integer li_rc |
|
1 |
li_rc = GetContextService( "TransactionServer", & |
|
1 |
txninfo_test ) |
|
1 |
// Handle error if necessary |
|
1 |
|
1 |
// Impersonate the client |
|
1 |
txninfo_test.<span>ImpersonateClient</span>() |
|
1 |
// Perform processing with client security context |
|
1 |
... |
|
1 |
// Revert to server's security context |
|
1 |
txninfo_test.RevertToSelf() |