ServiceControl Permissions

L

Laidbak

I seem to be getting an error saying I can't control services from an aspx page.
This code works:

private void Page_Load(object sender, System.EventArgs e)
{
/* Global Settings */
pcanywhereControl = new ServiceController("pcAnywhere Host Service");

/* put a title on the page */
TitleLabel.Text = pcanywhereControl.DisplayName.ToString();

StatusLabel.Text = pcanywhereControl.Status.ToString();

if (pcanywhereControl.Status.ToString() == "Running")
{
StartButton.Enabled = false;
}
else
{
StartButton.Enabled = true;
}
}


however, this code gives the following message:

"Cannot open awhost32 service on computer '.'."

private void Page_Load(object sender, System.EventArgs e)
{
/* Global Settings */
pcanywhereControl = new ServiceController("pcAnywhere Host Service");

/* put a title on the page */
TitleLabel.Text = pcanywhereControl.DisplayName.ToString();

StatusLabel.Text = pcanywhereControl.Status.ToString();

if (pcanywhereControl.Status.ToString() == "Running")
{
StartButton.Enabled = false;
}
else
{
StartButton.Enabled = true;
}
}


I need to be able to do this without running the asp.net user as
an administrator.

____________________________________
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
DigitallySmooth Inc. | Quick Site Studio
 
L

Laidbak

Good show...
I added the following line to the app's web.config

<identity impersonate="true"/>

I then made sure "Integrated Windows Authentication"
was checked under directory security.

All is well.
____________________________________
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
DigitallySmooth Inc. | Quick Site Studio
Depending on your environment, you might be able to use impersonation
and allow your code to run in the security context of the requestor.

See http://support.microsoft.com/default.aspx?scid=kb;en-us;317012
and http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158
for more info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top