View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Sauron[_16_] Sauron[_16_] is offline
external usenet poster
 
Posts: 1
Default VBA, Impersonating other user

Cheers Rob,

Thanks very much your a hero!

Found this based on your excellent advice;

Thanks Again,
Sau

Const LOGON_INTERACTIVE = 2
Const LOGON_NETWORK = 3
Const LOGON_BATCH = 4
Const LOGON_SERVICE = 5

Dim oNet
Set oNet = CreateObject("Wscript.Network")
MsgBox oNet.UserDomain & "\" & oNet.UserName

Dim impo
Set impo = CreateObject("sfImpersonator.Impostor")

'The dot in the third parameter is the domain name - "." means loca
domain
impo.Impersonate "UserName", "Password", ".", LOGON_INTERACTIVE
MsgBox oNet.UserDomain & "\" & oNet.UserName

impo.RevertToSelf
MsgBox oNet.UserDomain & "\" & oNet.UserNam

--
Message posted from http://www.ExcelForum.com