Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA, Impersonating other user

Hi All!

My spreadsheet needs to modify certain registry values (DSN serve
paths) which when the users open the spreadsheet will write themselve
to the registry.

Unfortunately the users don't have rights to modify these registr
values themselves so I was wondering if anyone knew how to impersonat
another user in VBA? (have a domain admin account that I can use).

Please don't say I have to get off my chair and walk round (they ar
miles away!)

Cheers,
Sa

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA, Impersonating other user

Would anyone know how to do this? There's about 50 users in all that I'
have to go round annoyingly...

Cheers,
Sa

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default VBA, Impersonating other user

"Sauron " wrote in message
...
Would anyone know how to do this? There's about 50 users in all that I'd
have to go round annoyingly...


Hi Sau,

VBA always runs within the security context of the currently logged in
user, so as far as I know there is no way to do this. You may be able to
accomplish this using WMI:

http://msdn.microsoft.com/library/de...pi_for_wmi.asp

However, I'm no expert on this so you'll be more likely to get a definitive
answer in one of the Windows groups,
microsoft.public.windows.server.scripting would seem like a good place to
start.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *



  #4   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining user access (via user id) using macros maruko Excel Discussion (Misc queries) 0 July 27th 09 02:44 AM
How do I report to User A vs User B from shared data table? RogClark Excel Discussion (Misc queries) 0 April 30th 09 07:54 PM
How do I format a cell, so the user must use a user calendar? nathan Excel Discussion (Misc queries) 1 January 16th 06 06:40 PM
How do I format a cell, so the user must use a user calendar? nathan Excel Discussion (Misc queries) 0 January 16th 06 05:26 PM
How to: Make user click End User License Agreement acceptance jasonsweeney[_21_] Excel Programming 7 January 30th 04 01:41 AM


All times are GMT +1. The time now is 06:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"