CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.security Tags:
Item Type: NewsGroup Date Entered: 12/20/2005 10:27:04 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 55 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
odin_dark
Asp.Net User
Check services on remote machine12/20/2005 10:27:04 PM

0/0

Hello, I'm trying to check the services status on a remote machine, the code i'm using is the next:

string MachineName = "somename"

ServiceController[] services = ServiceController.GetServices( MachineName );

foreach( ServiceController service in services ) {

Console.Write(string.Format( "{0} [ {1} ]", service.ServiceName, service.Status.ToString() ) );

}

 

this works fine if i execute it on a windows C# application, but it doesn't work if i try to execute it on an ASP .NET WEB Application, it sends the next error when i try to get the services:

System.InvalidOperationException: Cannot open Service Control Manager on computer 'somename'. This operation might require other privileges.

Someone can help???

 

 


David Banister
Asp.Net User
Re: Check services on remote machine12/22/2005 9:10:32 AM

1/1

The ASPNET account is a local account and has no privilidges on the remote machine. You need to use an account with permissions on the remote machine.
odin_dark
Asp.Net User
Re: Check services on remote machine12/22/2005 3:49:09 PM

1/1

Ok, and how can i do that? i found some ImpersonationUtil, the code is the next, but it doesn't work

public class ImpersonationUtil {
        public static bool Impersonate( string logon, string password, string domain ) {
            WindowsIdentity tempWindowsIdentity;
            IntPtr token = IntPtr.Zero;
            IntPtr tokenDuplicate = IntPtr.Zero;

            if( LogonUser( logon, domain, password, LOGON32_LOGON_INTERACTIVE,
                LOGON32_PROVIDER_DEFAULT, ref token) != 0 ) {

                if ( DuplicateToken( token, 2, ref tokenDuplicate ) != 0 ) {
                    tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
                    impersonationContext = tempWindowsIdentity.Impersonate();
                    if ( null != impersonationContext ) return true;               
                }           
            }

            return false;
        }

        public static void UnImpersonate() {
            impersonationContext.Undo();
        }

        [DllImport("advapi32.dll", CharSet=CharSet.Auto)]
        public static extern int LogonUser(
            string lpszUserName,
            String lpszDomain,
            String lpszPassword,
            int dwLogonType,
            int dwLogonProvider,
            ref IntPtr phToken );

        [DllImport("advapi32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]
        public extern static int DuplicateToken(
            IntPtr hToken,
            int impersonationLevel, 
            ref IntPtr hNewToken );

        private const int LOGON32_LOGON_INTERACTIVE = 2;
        private const int LOGON32_LOGON_NETWORK_CLEARTEXT = 4;
        private const int LOGON32_PROVIDER_DEFAULT = 0;
        private static WindowsImpersonationContext impersonationContext;
    }

odin_dark
Asp.Net User
Re: Check services on remote machine12/23/2005 2:38:42 PM

0/0

ok. now i found the way to do it, we just have to put the next code in the web.config file:

<identity impersonate="true" userName="userName" password="password" />

obviously the user must have access to these services on the remote machine

Thanks to all!
 

jballhrb
Asp.Net User
Re: Check services on remote machine2/13/2006 9:03:10 PM

0/0

How is this accomplished in a Web Application? I am trying to use the code in one, and am unsuccessful. Does it only work in a Windows Application and not a Web Application?

Can you port the entire code for your aspx page?

reshmap
Asp.Net User
Re: Check services on remote machine7/3/2007 8:01:23 AM

0/0

Hello,

           I was using the same code to check for the services through windows application using c#.net and it was working fine. Recently I had changed one of my service names and since then its giving the error

Cannot open Service Control Manager on Computer "ComputerName". This operation might required other privileges.

And my account has administrator permissions on the remote computer.

Any help is appreciated.

Thanks
 

6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Windows Server. Трюки Authors: Mitch Tulloch, Митч Таллоч, Safari Tech Books Online, Safari Tech Books Online, Pages: 357, Published: 2004
MCAD/MCSD: Developing XML Web Services and Server Components with Visual C# . NET and the . NET Framework Authors: Amit Kalani, Ed Tittel, Pages: 1040, Published: 2003
Digital Systems and Applications Authors: Vojin G. Oklobdzija, Alan Jeffrey, Pages: 992, Published: 2007
Borland C++ Builder 6 Developer's Guide Authors: Bob Swart, Jarrod Hollingworth, Mark Cashman, Paul Gustavson, Pages: 1097, Published: 2003
Beginning Ruby: From Novice to Professional Authors: Peter Cooper, Pages: 631, Published: 2007
High-performance Computing and Networking: 9th International Conference, HPCN Europe, 2001, Amsterdam, The Netherlands, June 25-27, 2001 : Proceedings Authors: Bob Hertzberger, Alfons Hoekstra, Roy D. Williams, Pages: 733, Published: 2001
IMac for Dummies Authors: Mark L. Chambers, Pages: 408, Published: 2008
Microsoft Windows Server 2003 Unleashed: Unleashed Authors: Rand Morimoto, Michael Noel, Alex Lewis, Pages: 1317, Published: 2006
The Unauthorized Guide to Windows 98 Authors: Paul McFedries, Pages: 784, Published: 1999

Web:
Check services on remote machine - ASP.NET Forums Hello, I'm trying to check the services status on a remote machine, the code i'm using is the next:. string MachineName = "somename" ...
Code to check status of specified services on remote machine ... 1) I can only check services on the local machine, how can I check services on a remote machine? 2) How can I convert the checked items of a ...
checking a service on a remote machine : remote I was wondering if it is possiable to check remote services on a remote comptuter ... must be running as a user who has admin privs on the remote machine, ...
Monitoring Window services in local and remote machine - .Net ... To retrieve services from remote machine, pass machine name as parameter to the ... To check whether a service can stop or pause, Service Controller exposes ...
University of Georgia: Office of the Chief Information Officer ... If you can get to the remote machine, make sure that File Sharing services are enabled. Open the Sharing control panel on the remote machine and check. ...
Querying a Remote Machine Configure Query SCU Service Properties. Before querying a remote machine, ... To check what query models are supported by the remote node, use the Echo SCU ...
RE: any plugins to check oracle on remote machine?: msg#00043 If it doesn't work see NSClient, or NRPE_NT services to check Windows running ... Objet : [Nagiosplug-help] any plugins to check oracle on remote machine? ...
WebService test form from remote machine Is it possible to access the web service from a remote machine via a ... I would check out in my client application (the one that will access the web ...
IT Resource Center forums - Cannot open the attachments from ... We have configured attachments settings in service desk 5.1 with patch 3, and i can open the ... check the personal f/w on remote machine. ...
BrowserCam : Screen capture and Remote Access service for cross ... Check javascripts, DHTML, forms and other dynamic functionality on any ..... The Remote Access Service allocates a dedicated machine exclusively for you. ...

Videos:
Actual Remote Computer Support Session Our Customer was not sure how to to change their default printer setting and was not able to wait for computer tech to arrive so we tried resolving b...
Mini Remote Control Plane For Sale - Indoor Flyer - Sale (safe mini link) http://www.kqzyfj.com/click-1264614-10428473 Mini Remote Control Plane For Sale - Indoor Flyer. RaidonTech. Discount Hobby SuperSt...
Easy Radio Controled Airplanes To Purchase - Flying Spaceman (safe easy link) http://www.kqzyfj.com/click-1264614-10428473 Easy Radio Controled Airplanes To Purchase - Flying Spaceman. RadonTech. Discount Hob...
Nitro Radio Control War Toys Sales - Tank - Low Priced (safe nitro link) http://www.kqzyfj.com/click-1264614-10428473 Nitro Radio Control War Toys Sales - Tank. Raden Tech. Discount Hobby SuperStore. Ra...
The Queue: Week in review WHAT IS GOING ON... I'M RICH DEMURO WITH CNET TV AND THIS IS THE QUEUE...WEEK IN REVIEW. HERE WE TAKE A LOOK AT THE TOPS IN TECH FOR THE SECOND WEEK ...
(888)MOAX.ORG Microsoft Offfice Accounting Xchange 4_IT_JOURNAL.wmv (888)MOAX.ORG Microsoft Offfice Accounting Xchange 4_IT_JOURNAL.wmv - 31 min - Apr 23, 2008 USStudios - http://www.onafree.com (1 Rating) Rate: (...
myHotelVideo.com presents: Hotel CityLife Heritage Wellington in Wellington / New Zealand / New Zealand More @ http://myhotelvideo.com/de/landingpage/youtube/resourceid/Mhv_Catalog_Offer::88966 Location: Whether it is for business or pleasure, the prime...
A New Way to look at Networking Google Tech Talks August 30, 2006 Van Jacobson is a Research Fellow at PARC. Prior to that he was Chief Scientist and co-founder of Packet Design. P...
Distributed continuous quality assurance Google London Test Automation Conference (LTAC) Google Tech Talks September 8th, 2006 Presenter: Adam Porter
Zero Configuration networking with Bonjour Google TechTalks November 2, 2005 Dr. Stuart Cheshire, Apple Computer http://www.stuartcheshire.org/ ABSTRACT The desirability of making IP networ...




Search This Site:










how about another skinning contest, eh?

dnn and online store

single sign-on and active directory

problem with ~/ in master page path.

dotnetnuke website - missing ley item

trying to use exception and logging application block in a website

navigation control/ menu

why is howdy doody an administrator?

asp.net server component

folder and file access

personalization to ignore case in url?

looping through controls in master pages

i have a problem in design mode

catalog zone checkboxes

custom images in module

getting profile connection string

force windows login for impersonated application

when lastactivedate get update?

tab control image problem

unable to open project in vs

treeview using web.sitemap

dnn 3.0.11 issue compiling in visual studio

keeping the parentnode selected when on a childnode page.

howto avoid to load all the stylesheet files in a theme?

using mysql with members, roles, and profiles

asp net account

adding custom controls

include asp.net file

dynamically set menu items width to percentage programmatically

passing username in a url of links module

 
All Times Are GMT