Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting error object required: server...any ideas?

Status
Not open for further replies.

scotitpulsa

IS-IT--Management
Oct 1, 2003
61
US
here is my snippet of code:

Dim oStore
Dim user
Dim password

Set oStore = Server.CreateObject("ANPOP.MSGSTORE")
Set user = "*******"
Set password = "********"


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
 
The Server object is used in asp pages for server side scripting.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How would I impersonate a user (such as an admin) to look for and delete files from the root of C, using a VB Script? With this code work with modifications?
 
I've tried this code....but get a type mismatch error at logonUser:

''Sub main(args)
Dim user
Dim domain
Dim password
'' set these in your environment, or here in the script
'' If you're running as a service, you will need to set these
'' as SYSTEM variables

user = "**********"
domain = "**********"
password = "**********"

'' logon as user X
Dim hToken
hToken = LogonUser(user,domain,password) ',LOGON32_LOGON_BATCH,LOGON32_PROVIDER_DEFAULT)

'' Impersonate user X
Dim ilu
ilu = ImpersonateLoggedOnUser(hToken)

'' do whatever you want to do as user X
If ilu = true Then
'Print ("This thread is now running as " + user)
dim feedback_old, intranet_old, nextish_old, pulsabg_old

feedback_old = "c:\documents and settings\all users\desktop\feedback.url"
'intranet_old = "c:\documents and settings\all users\desktop\Rochester Intranet.url"
'nextish_old = "c:\nextish.ico"
'pulsabg_old = "c:\pulsabg.gif"

if fs.fileexists(feedback_old) = true then
set feedback_old = fs.GetFile(feedback_old)
feedback_old.delete
end if

'if fs.fileexists(intranet_old) = true then
' set intranet_old = fs.GetFile(intranet_old)
' intranet_old.delete
'end if

'if fs.fileexists(nextish_old) = true then
' set nextish_old = fs.GetFile(nextish_old)
' nextish_old.delete
'end if

'if fs.fileexists(pulsabg_old) = true then
' set pulsabg_old = fs.GetFile(pulsabg_old)
' pulsabg_old.delete
'end if
msgbox("impersonation succeeded")
Else
'Print ("Unable to become " + user)
msgbox("impersonation failed")
End If

'' all done with this user
FreeHandle(hToken)

'' terminate impersonation for this thread
RevertToSelf

'End Sub
 
Where are LogonUser() and ImpersonateLoggedOnUser() coming from ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top