Click here to Skip to main content
15,922,523 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am getting this error Cannot open Service Control Manager on computer ''. This operation might require other privileges while using ServiceController to retrieve the services of remote machine. I have administrative previleges for remote machine..
Code..
C#
ServiceController[] lFnGetServicesInServer(string lStrServer)
        {
            try
            {
                ServiceController[] lArrObjServiceController = null;
                System.Security.Principal.WindowsImpersonationContext impersonationContext = null;
                impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
                lArrObjServiceController = ServiceController.GetServices(lStrServer.Trim());
                return lArrObjServiceController;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

    }


Any Ideas on this authentication plzz…
Thanks
Sreenath
Posted
Updated 26-Sep-16 2:43am
v2

The computer name appears to be empty ('').
You can put a break point on the method signature and then check if the correct server name values are being passed in.
 
Share this answer
 
As you are sure that you have admin previleges & server name is correctly passed,please try restarting the machine.It may help!
 
Share this answer
 
Server and Client machine should have same user account, to access the Service List.
 
Share this answer
 
yeah..I have debugged the code...Server name is sent perfectly correct and I can acces the remote desktop for the same server too..!
 
Share this answer
 
Yeah I do have...I even have deployed projects in this server with the same and monitored regurarly.
 
Share this answer
 
Comments
Anupama Roy 7-Feb-11 1:09am    
I would suggest,you add your comments in comments section rather than adding as answer.That will send out a notification to person who has provided you answer.I ran your code in my system & would like to add my observation here.When I gave a valid server name it works fine.At the same time when server name is not existing ie giving a wrong server it throws the same exception what you are getting.hence,double check if server name is correctly passed & your system is offline or not at this moment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900