RevertToSelf Method

Log off user which logon with ImpersonateUser method

[Syntax]
C++: HRESULT RevertToSelf()
Visual Basic: RevertToSelf()
C#: void RevertToSelf()

Remarks

This method logs off current impersonated user with ImpersonateUser method. Normally, ASP/ASP.NET applications run under the security context of IUSER_MACHINENAME user, this user doesn't have enough permission to access all files on server. Therefore, many file operations would be failed in ASP/ASP.NET applications such as ExportFile, SaveAttachment, ImportFile and so on. ImpersonateUser method provides a way to run your ASP/ASP.NET applications under administrator or any other user so that POPMSG object has enough permission to access files.

This method can impersonate another use to run this object on current computer or domain. Normally, ASP/ASP.NET applications run under the security context of IUSER_MACHINENAME user, this user doesn't have enough permission to access all files on server. Therefore, many file operations would be failed in ASP/ASP.NET applications such as ExportFile, SaveAttachment, ImportFile and so on. ImpersonateUser method provides a way to run your ASP/ASP.NET applications under administrator or any other user so that POPMSG object has enough permission to access files.

Usage Example

[ASP/VBScript]
Dim oStore
Dim user, password

oStore = Server.CreateObject("ANPOP.MSGSTORE")
user = "administrator"
password = "ad1234"

If oMsg.ImpersonateUser( user, password, "" ) = 0 Then 'logon this user
  Response.Write "Impersonate user succeeded"
Else
  Response.Write "Impersonate user failed"
End If

oStore.RevertToSelf 'log off this user and run oMsg with original user
[ASP.NET/Visual Basic]
Dim oStore As ANPOPLib.MSGSTOREClass()
oStore = Server.CreateObject("ANPOP.MSGSTORE")

Dim user, password As String
user = "administrator"
password = "ad1234"

If oStore.ImpersonateUser( user, password, vbNullString ) = 0 Then 'logon this user
  Response.Write( "Impersonate user succeeded" )
Else
  Response.Write( "Impersonate user failed" )
End If

oStore.RevertToSelf() 'log off this user and run oMsg with original user
[ASP.NET/C#]
ANPOPLib.MSGSTOREClass oStore = 
               (ANPOPLib.MSGSTOREClass)Server.CreateObject("ANPOP.MSGSTORE");
string user = "administrator", password = "ad1234";

if( oStore.ImpersonateUser( user, password, null ) == 0 ) //logon this user
  Response.Write( "Impersonate user succeeded" );
else
  Response.Write( "Impersonate user failed" );
  
oStore.RevertToSelf(); //log off this user and run oMsg with original user

See Also

ImpersonateUser Method


2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.