Su Method


Simulate another user to logon server.

long Su(
	[in] BSTR Session, 
	[in] BSTR User, 
	[in] BSTR Server, 
	[in] BSTR RequestAddr
)

Parameters

Session

Session key of current user.

User

User to be simulated

Server

Server name or IP address

RequestAddr

IP address of current logon machine.

Return Value

Return value is zero if this method succeeds; otherwise return value is non-zero.

Remarks

This method is similar to command "su" under UNIX/Linux. It can logon as another user from current user session key. "system" user can simulate any user in server; domain administrator can only simulate users under the same domain; normal user can't simulate other users.

Usage Example

Const SESSION_REQUIRED = 1
Dim server, user, password, sessionkey, requestAddr
server = "localhost"
user = "system"
password = "mypassword"
requestAddr = "192.168.0.1"

Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
'Connect with session required
r = oSvr.Connect( server, user, password, SESSION_REQUIRED, requestAddr ) 
If r <> 0 Then
  WScript.Echo( "connect server failed!" )
  WScript.Quit
End If

'get session key generated by server.
sessionkey = oSvr.SessionKey
oSvr.Close

'now connect server with session key to simulate user "tester@adminsystem.com" 
once this method succeeded, current object has user "tester@adminsystem.com" security context
r = oSvr.Su( sessionkey, "tester@adminsystem.com", server, requestAddr )
If r <> 0 Then
  WScript.Echo( "Su method failed!" )
  WScript.Quit
End If

See Also

Using EmailArchitectObjects
EmailArchitectObjects Remote Access
Connect
OpenSession