473,414 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

WinForm as LocalService

Hello everybody...

i reeeealy need a way to automatically execute a WinForm with the same
permissions that i have with the LocalService user.

Thanks in advance...

May 31 '07 #1
10 2378
Hi,

It depend of the user you are logged like. The app will have the same
privilegies

Take a look at the WindowsIdentity class, you can use it to impersonate
other users

What is what you want to do?
"IsRaEl" <yz****@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
Hello everybody...

i reeeealy need a way to automatically execute a WinForm with the same
permissions that i have with the LocalService user.

Thanks in advance...

May 31 '07 #2
On 31 May 2007 06:47:17 -0700, IsRaEl wrote:
i reeeealy need a way to automatically execute a WinForm with the same
permissions that i have with the LocalService user.
What permissions of the LocalService user does your application need? Why
does it have to be a WinForm?

You can get a Windows Service running under the LocalService account to
display a Form on the screen by checking the Allow Service to Interact with
Desktop but this won't work anymore in Vista and any case might cause you
loads of troubles and pose a serious security risk.

My guess is that running a WindowForm application under the LocalService
account is the wrong solution for your (I suppose real) problem. More
information about what you are really trying to achieve could help.
May 31 '07 #3
Ok..so here is what i got...

i have a Windows Service that use a WebService to send some
files...for that, in some places it needs a proxy config..

so, i've created a Windows App that use the same code to send 1 file
using the same WebService...i call it ConnectionTester...

The problem is, when you use the ConnectionTester and you're logged in
with the Machine Admin, or some Network Admin...the Tester sometimes
work's even without the proxy configuration...and when i use the
Windows Service, it only connect's with proxy correctly configured...

So, doing my own brainstorm, i think it's because the Windows Service
is on a LocalService account....and maybe, if execute teh
ConnectionTester with this account, i can have the exactly same
results...

thanks

May 31 '07 #4
IsRaEl,

So, in this case, run the service with an account which has the
appropriate permissions to do what you need it to do. You can right click
on the service and then choose the account that it runs under.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"IsRaEl" <yz****@gmail.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
Ok..so here is what i got...

i have a Windows Service that use a WebService to send some
files...for that, in some places it needs a proxy config..

so, i've created a Windows App that use the same code to send 1 file
using the same WebService...i call it ConnectionTester...

The problem is, when you use the ConnectionTester and you're logged in
with the Machine Admin, or some Network Admin...the Tester sometimes
work's even without the proxy configuration...and when i use the
Windows Service, it only connect's with proxy correctly configured...

So, doing my own brainstorm, i think it's because the Windows Service
is on a LocalService account....and maybe, if execute teh
ConnectionTester with this account, i can have the exactly same
results...

thanks

May 31 '07 #5
On May 31, 1:05 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
IsRaEl,

So, in this case, run the service with an account which has the
appropriate permissions to do what you need it to do. You can right click
on the service and then choose the account that it runs under.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"IsRaEl" <yzr...@gmail.comwrote in message

news:11**********************@u30g2000hsc.googlegr oups.com...
Ok..so here is what i got...
i have a Windows Service that use a WebService to send some
files...for that, in some places it needs a proxy config..
so, i've created a Windows App that use the same code to send 1 file
using the same WebService...i call it ConnectionTester...
The problem is, when you use the ConnectionTester and you're logged in
with the Machine Admin, or some Network Admin...the Tester sometimes
work's even without the proxy configuration...and when i use the
Windows Service, it only connect's with proxy correctly configured...
So, doing my own brainstorm, i think it's because the Windows Service
is on a LocalService account....and maybe, if execute teh
ConnectionTester with this account, i can have the exactly same
results...
thanks
But i want to run the app as a LocalService...is that impossible?

May 31 '07 #6
On Thu, 31 May 2007 15:01:45 +0100, Mehdi wrote:
On 31 May 2007 06:47:17 -0700, IsRaEl wrote:
>i reeeealy need a way to automatically execute a WinForm with the same
permissions that i have with the LocalService user.

What permissions of the LocalService user does your application need? Why
does it have to be a WinForm?

You can get a Windows Service running under the LocalService account to
display a Form on the screen by checking the Allow Service to Interact with
Desktop but this won't work anymore in Vista and any case might cause you
loads of troubles and pose a serious security risk.
Forget that, I missread your post. I had read LocalSystem when you really
wrote LocalService. You can't do the Interact with Desktop trick with the
LocalService account.
May 31 '07 #7
On 31 May 2007 07:24:48 -0700, IsRaEl wrote:
i have a Windows Service that use a WebService to send some
files...for that, in some places it needs a proxy config..

so, i've created a Windows App that use the same code to send 1 file
using the same WebService...i call it ConnectionTester...

The problem is, when you use the ConnectionTester and you're logged in
with the Machine Admin, or some Network Admin...the Tester sometimes
work's even without the proxy configuration...and when i use the
Windows Service, it only connect's with proxy correctly configured...

So, doing my own brainstorm, i think it's because the Windows Service
is on a LocalService account....and maybe, if execute teh
ConnectionTester with this account, i can have the exactly same
results...
Maybe, maybe not. Don't take offense but it seems to me that instead of
trying to find the root of the problem and to solve it, you're simply
trying out some random tricks to get around the problem. Even if you manage
to get your WindowForm application to run under the LocalService account
and even if it *seems* to work this way, the problem will still be there.

If I understand you properly, the computer on which your application runs
needs to go through a proxy server in order to access the Web Service. Your
Windows Service application automatically picks up the proxy server
configuration when it connect but your WindowForm application doesn't. What
about looking at the APIs that allow you to retrieve the proxy server info
from, for example, Internet Explorer's settings and set this info when
connecting to a Web Service? That would sound a lot more sensible to me
than trying to run your application under some random user account that
you've found always worked for some reason you can't explain.
May 31 '07 #8
Why do you want to run the service under the LocalService account if it
doesn't allow you to do what you need it to do? The other option is to
change the rights of the LocalService account to allow it to do what you
need to do, but then that would affect all other services that run under the
LocalService account, which isn't a good idea.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"IsRaEl" <yz****@gmail.comwrote in message
news:11**********************@p47g2000hsd.googlegr oups.com...
On May 31, 1:05 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>IsRaEl,

So, in this case, run the service with an account which has the
appropriate permissions to do what you need it to do. You can right
click
on the service and then choose the account that it runs under.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"IsRaEl" <yzr...@gmail.comwrote in message

news:11**********************@u30g2000hsc.googleg roups.com...
Ok..so here is what i got...
i have a Windows Service that use a WebService to send some
files...for that, in some places it needs a proxy config..
so, i've created a Windows App that use the same code to send 1 file
using the same WebService...i call it ConnectionTester...
The problem is, when you use the ConnectionTester and you're logged in
with the Machine Admin, or some Network Admin...the Tester sometimes
work's even without the proxy configuration...and when i use the
Windows Service, it only connect's with proxy correctly configured...
So, doing my own brainstorm, i think it's because the Windows Service
is on a LocalService account....and maybe, if execute teh
ConnectionTester with this account, i can have the exactly same
results...
thanks

But i want to run the app as a LocalService...is that impossible?

May 31 '07 #9
On May 31, 1:22 pm, Mehdi <vio...@REMOVEME.gmail.comwrote:
On 31 May 2007 07:24:48 -0700, IsRaEl wrote:
i have a Windows Service that use a WebService to send some
files...for that, in some places it needs a proxy config..
so, i've created a Windows App that use the same code to send 1 file
using the same WebService...i call it ConnectionTester...
The problem is, when you use the ConnectionTester and you're logged in
with the Machine Admin, or some Network Admin...the Tester sometimes
work's even without the proxy configuration...and when i use the
Windows Service, it only connect's with proxy correctly configured...
So, doing my own brainstorm, i think it's because the Windows Service
is on a LocalService account....and maybe, if execute teh
ConnectionTester with this account, i can have the exactly same
results...

Maybe, maybe not. Don't take offense but it seems to me that instead of
trying to find the root of the problem and to solve it, you're simply
trying out some random tricks to get around the problem. Even if you manage
to get your WindowForm application to run under the LocalService account
and even if it *seems* to work this way, the problem will still be there.

If I understand you properly, the computer on which your application runs
needs to go through a proxy server in order to access the Web Service. Your
Windows Service application automatically picks up the proxy server
configuration when it connect but your WindowForm application doesn't. What
about looking at the APIs that allow you to retrieve the proxy server info
from, for example, Internet Explorer's settings and set this info when
connecting to a Web Service? That would sound a lot more sensible to me
than trying to run your application under some random user account that
you've found always worked for some reason you can't explain.
no offense taken...hehehe

this part of taking the proxy config from IE i already do...here is my
code:
if(CboProxy.Checked)
{
WebProxy Proxy = new WebProxy(TxtIPProxy.Text,
Convert.ToInt32(TxtPortaProxy.Text));
Proxy.BypassProxyOnLocal = true;
STA.Proxy = Proxy;

CredentialCache cache = new CredentialCache();
// Verifica o overload correto das credenciais
if(TxtUsuario.Text == "" && TxtDominio.Text == "")
cache.Add( new Uri(STA.Url), "Negotiate", new
NetworkCredential());
else if(TxtDominio.Text == "")
cache.Add( new Uri(STA.Url), "Basic", new
NetworkCredential(TxtUsuario.Text, TxtSenha.Text));
else
cache.Add( new Uri(STA.Url), "Negotiate", new
NetworkCredential(TxtUsuario.Text, TxtSenha.Text, TxtDominio.Text));
STA.Credentials = cache;
STA.Proxy.Credentials = cache;
}
else
{
STA.Credentials = System.Net.CredentialCache.DefaultCredentials;
}

and i can't predict in what computer it will run...and if will run on
a Vista, XP, 2003 server, 2000 server...and if will use a proxy or
not...
it will be installed in a lot of locations...

and about change the LocalService permissions, sometimes the client
may not agree with that..

i need only to run my Win App with a LocalService account...

May 31 '07 #10
On 31 May 2007 10:04:12 -0700, IsRaEl wrote:
this part of taking the proxy config from IE i already do...here is my
code:
[...]
and i can't predict in what computer it will run...and if will run on
a Vista, XP, 2003 server, 2000 server...and if will use a proxy or
not...
it will be installed in a lot of locations...

and about change the LocalService permissions, sometimes the client
may not agree with that..

i need only to run my Win App with a LocalService account...
Unfortunately, I won't be able to help you with the Proxy Server settings
problem as I haven't had to use proxy servers so far.

However, I am still convinced that your problem, if I understood it
correctly, lies in finding a way to set the proper proxy settings in the
Windows Form application and has nothing to do with the user account the
application runs under. The fact that it always works with a Windows
Service running under the LocalService account might be just pure
coincidence and be caused by some other factor than the specific user
account that your code runs under. Have you read the documentation about
the LocalService account to try to find out if this account has any
specific features that would explain why your code works under LocalServer
but not under Administrator?

I do not know whether it is even possible to run a standard Window Forms
application under the LocalService account but what's for sure is that
doing that would be a very bad idea as this account as been created
specifically to run background Windows Services that need to run under a
restricted account with anonymous access to LAN ressources. Is has never
been designed to run Windows Form applications and you'll probably
encounter all sorts of security problem if you try to do that.
Jun 1 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: localhost | last post by:
I am looking for any info on creating an MDI WinForms application that uses the "main executable" as a main window container (along with a menu), but can launch other .exe from a menu that act as...
0
by: cgia | last post by:
I found out that only using winform I can use the winword interop and generate word document in the client machine and connect to a remote database, so that I have made a winform application which...
0
by: zbcong | last post by:
hello in my winform,there is a datagrid,i want to fire some actions when the selected index is changed,but i fail to find the SelectedIndexChanged event to the winform datagrid,why? how can i...
3
by: Skc | last post by:
My client's project consists of about 6 files maintenance programs that uses WinForm and grid for updates with lookup finders for each file. There is also a User file and security. There are...
2
by: J.Marsch | last post by:
Ok, so here's a problem you probably don't see every day: We are building an application that must run in a browser, but we need to do some things client-side that would be rather difficult to...
8
by: Sunil Menon | last post by:
Dear All, We are developing applications in ASP.Net...in one of our applications we would like to use a GridControl...we have tried to use a Server-Side Grid control but found the speed to be an...
2
by: jyanmin.fang | last post by:
Hi, In my current project, I need to embed an .NET winform usercontrol in the aspx page (via <Objecttag). This winform usercontrol has an event called DoEvent (void DoEvent()). This winform...
0
by: Tom | last post by:
Hi all -- this is my first posting here and I want to start by saying thank you to all the responders. I have done some searching and reading and have learned a few things I didn't even know to...
14
by: Monty | last post by:
Hello, I have created a solution which has both a web UI and a winform UI, the latter is just for administrators. The Web UI (a Web Application Project) and the winform project both...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.