RE: Different credentials for remote registry/SCM access



Hi Steve,

Based on my understanding, you wanted to write a customized application to
allow the normal user to remote stop/retart Windows Services and registry
configuration. However, since these operations requires Admin right, you
want to find a way to run your application under Admin security context for
a moment for these high privilege tasks. If I have misunderstood you,
please feel free to tell me, thanks.

Yes, your requirement is a classic impersonation usage. Since you have the
username/password of the Admin account, your application can call LogonUser
API with username/password of Admin to launch a Admin account's logon
session. This API will return a security token which is a handle points to
the logon session.

Then you should first call DuplicateToken API to translate this primary
token into a impersonation token by passing SecurityImpersonation as the
second parameter.(Translating primary token into impersonation token is the
requirement of SetThreadToken API) And then calling SetThreadToken API to
set the current thread token as Admin's security impersonation token, so
that your current thread is executing under the Admin's security context.
Then you may perform all the high privilege tasks now. This process is
called as Impersonation in Windows security programming.

After performing the tasks, you may call RevertToSelf API to return to the
original user security context. This is critical, since from security
perspective, you really wanted to limit the high privilege executing time
to minimum.

The article below demonstrates the logic in C#:
"Windows Impersonation using C#"
http://www.codeproject.com/csharp/cpimpersonation1.asp

My reply below provided a working code snippet in C/C++:
http://groups.google.com/group/microsoft.public.win32.programmer.kernel/msg/
679a95c3a4d1af5a?hl=zh-CN&

Finally. caching the password in application has a high security concern,
to deal with password more securely, you may follow the suggestions in the
article below:
"Handling Passwords"
http://windowssdk.msdn.microsoft.com/en-us/library/ms717799.aspx

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • FW: {RTCProd#003-520-317}Windows Update Support Request
    ... support policy for Windows NT 4.0 Workstation SP6a. ... The Microsoft Support Lifecycle defines the support policies for all ... This means that after this date, Microsoft would no longer create ... security fixes for this platform, nor automatically post to WU, etc. ...
    (NT-Bugtraq)
  • (no subject)
    ... Look at the Navy-Marine Corps Internet, a contract ... Security is secuirty and penetration means exactly that. ... You just hit a sore spot w/ me...the CSI/FBI survey. ... it's probably an admin who has ...
    (comp.security.misc)
  • (no subject)
    ... Look at the Navy-Marine Corps Internet, a contract ... Security is secuirty and penetration means exactly that. ... You just hit a sore spot w/ me...the CSI/FBI survey. ... it's probably an admin who has ...
    (comp.os.ms-windows.nt.admin.security)
  • Re: Food for Thought
    ... Look at the Navy-Marine Corps Internet, a contract ... Security is secuirty and penetration means exactly that. ... that telling the reader to do a Google search for sources isn't going to ... it's probably an admin who has ...
    (microsoft.public.win2000.security)
  • Re: Grant Administrative Access to a Domain Controller
    ... Anyone with a good understanding of AD and Windows security will easily see ways of compromising the environment. ... Do not give enhanced rights to Domain Controllers to anyone you don't trust with Domain and/or Enterprise Admins. ... Just know that minimal access can be parlayed into even more access and try as you might, you cannot secure Active Directory from people with server operator or admin or several other levels of access rights on a DC. ...
    (microsoft.public.windows.server.active_directory)