Hi,
is it possible to get the environment variables for users other than the
user that is currently executing the application?
For example if I run a system service, how can the service find the
SpecialFolder.I nternetCache of a certain user?
Thanks for input. Dave. 3 3278
David,
You will have to call the SHGetFolderPath API through the P/Invoke layer
to get this. When you call it, you will have to create an impersonation
token for the user to pass in the hToken parameter, so you can get that
specific user's path information. This would mean a call to LogonUser to
get the impersonation handle representing that user.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"David Meier" <Da********@dis cussions.micros oft.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com... Hi,
is it possible to get the environment variables for users other than the user that is currently executing the application?
For example if I run a system service, how can the service find the SpecialFolder.I nternetCache of a certain user?
Thanks for input. Dave.
Hi Nicholas,
first, thanks for the reply. Does your solution mean, the service needs to
know the password for the user in order to get the impersonation handle? Is
there no other way?
Dave
"Nicholas Paldino [.NET/C# MVP]" wrote: David,
You will have to call the SHGetFolderPath API through the P/Invoke layer to get this. When you call it, you will have to create an impersonation token for the user to pass in the hToken parameter, so you can get that specific user's path information. This would mean a call to LogonUser to get the impersonation handle representing that user.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"David Meier" <Da********@dis cussions.micros oft.com> wrote in message news:CE******** *************** ***********@mic rosoft.com... Hi,
is it possible to get the environment variables for users other than the user that is currently executing the application?
For example if I run a system service, how can the service find the SpecialFolder.I nternetCache of a certain user?
Thanks for input. Dave.
David,
This would be the easy way to do it, but not practical at all.
Are you doing this in an operation that is not triggered by something
else? For example, is a call over a socket, or a named pipe being made to
you (or remoting). Something where you can flow the identity of the caller
to the service? If so, you should use impersonation to do that, otherwise,
you need to fabricate the token yourself.
You might be able to make a call to NtCreateToken (an undocumented
function, documentation at http://undocumented.ntinternals.net/...eateToken.html )
, but I'm not sure that it would work. If so, your calls would have to look
something like this:
UserSid = LookupAccountNa me(UserName);
EnablePrivilege (SeCreateTokenP *rivilege);
hToken = NtCreateToken(U serSid,UserGrou *p,UserPrivileg e);
DisablePrivileg e(SeCreateToken *Privilege);
From there, you can pass the token to the SHGetFolderPath API.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"David Meier" <Da********@dis cussions.micros oft.com> wrote in message
news:DA******** *************** ***********@mic rosoft.com... Hi Nicholas,
first, thanks for the reply. Does your solution mean, the service needs to know the password for the user in order to get the impersonation handle? Is there no other way?
Dave
"Nicholas Paldino [.NET/C# MVP]" wrote:
David,
You will have to call the SHGetFolderPath API through the P/Invoke layer to get this. When you call it, you will have to create an impersonation token for the user to pass in the hToken parameter, so you can get that specific user's path information. This would mean a call to LogonUser to get the impersonation handle representing that user.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"David Meier" <Da********@dis cussions.micros oft.com> wrote in message news:CE******** *************** ***********@mic rosoft.com... > Hi, > > is it possible to get the environment variables for users other than > the > user that is currently executing the application? > > For example if I run a system service, how can the service find the > SpecialFolder.I nternetCache of a certain user? > > Thanks for input. Dave. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Bowman |
last post by:
Hi All,
I've got a simple wrapper static test method on a class to expand the
environment variables on a specified string:
public static string ExpandEnvironmentStr(string Str)
{
return Environment.ExpandEnvironmentVariables(Str);
}
|
by: Edward |
last post by:
I've just taken over maintaining a system from a colleague who has
left. I find the following line in her code:
Dim params(2) As SqlClient.SqlParameter
params(0) = New SqlClient.SqlParameter("@UserName", pvstrUsername)
params(1) = New SqlClient.SqlParameter("@Password", pvstrPassword)
params(2) = New SqlClient.SqlParameter("@MachineName",
Environment.MachineName())
|
by: Dominic |
last post by:
My question is about how to maintain view state in mobile ASP.NET
across postback / request in a web farm environment.
First of all, let's assume the web-farm does NOT use stick-session
feature. In other words, different web servers may serve different
requests in the SAME session.
In non-mobile ASP.NET, my understanding is that the view state
information is passed between each client browser and server with
every post-back. Even if...
|
by: Rob Nicholson |
last post by:
A consequence of the ASP.NET architecture on IIS has just hit home with a
big thud. It's to do with shared variables. Consider a module like this:
Public Module Functions
Public GlobalName As String ' this is ineffect a global
application object
End Module
|
by: Fuzzyman |
last post by:
Hello all,
I would like to set a Windows Environment variable for another
(non-child) process.
This means that the following *doesn't* work : ::
os.environ = value
In the ``win32api`` package there is a ``GetEnvironmentVariable``
| |
by: Peter Kirk |
last post by:
Hi
I would like to ask a little bit about the value Environment.Newline: what
is it and what is the point of it? Ok, I can see in the docs that it
represents "newline" for the current platform - I assume that it is a
runtime property, and not compile time?
But won't it always be the same anyway - does dotnet run on anything other
than windows platforms? So isn't newline always the same?
|
by: ANarula |
last post by:
I am running into a strange problem. I have perl script which reads the
"APPDATA" environment variable, and does some work on that directory.
When I a launch this script from Command Prompt, it works perfectly fine,
however when the same script is launched from a DLL hosted in a particular
Service, the script fails to read the envrionment variable.
Does any one has any clue, whats going wrong ?
Regards,
|
by: Bjarne |
last post by:
Dear all,
although being a user of PHP and other scripting-languages for years, I
have not taken part in any large projects based on PHP. Thus, I don't
really know how real PHP-applications are deployed out there. This
posting is a request for input from professional PHP-users and
architects with experience from designing PHP applications.
My company makes a toolkit for developing WebServices. This toolkit is
typically used to expose an...
|
by: Henry Hollenberg |
last post by:
Hello,
I have written a script that uses environment variables set during
a particular users login in ".bash_profile" and ".profile".
I have changed to that users uid and gid in my python script using:
import os
os.setegid
os.setgid
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |