<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Security</title><link>http://forums.asp.net/25.aspx</link><description>All about ASP.NET security (authentication, authorization, membership, roles, etc.) and the Login controls. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=24&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Check services on remote machine</title><link>http://forums.asp.net/thread/1784309.aspx</link><pubDate>Tue, 03 Jul 2007 08:01:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1784309</guid><dc:creator>reshmap</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1784309.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=1784309</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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&lt;/p&gt;&lt;p&gt;Cannot open Service Control Manager on Computer &amp;quot;ComputerName&amp;quot;. This operation might required other privileges.&lt;/p&gt;&lt;p&gt;And my account has administrator permissions on the remote computer.&lt;/p&gt;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&lt;p&gt;Thanks&lt;br /&gt;&amp;nbsp; &lt;/p&gt;</description></item><item><title>Re: Check services on remote machine</title><link>http://forums.asp.net/thread/1196946.aspx</link><pubDate>Mon, 13 Feb 2006 21:03:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1196946</guid><dc:creator>jballhrb</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1196946.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=1196946</wfw:commentRss><description>&lt;p&gt;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?&lt;/p&gt;
&lt;p&gt;Can you port the entire code for your aspx page?&lt;/p&gt;</description></item><item><title>Re: Check services on remote machine</title><link>http://forums.asp.net/thread/1150461.aspx</link><pubDate>Fri, 23 Dec 2005 14:38:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1150461</guid><dc:creator>odin_dark</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1150461.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=1150461</wfw:commentRss><description>ok. now i found the way to do it, we just have to put the next code in the web.config file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;identity impersonate="true" userName="userName" password="password" /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
obviously the user must have access to these services on the remote machine&lt;br /&gt;
&lt;br /&gt;
Thanks to all!&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: Check services on remote machine</title><link>http://forums.asp.net/thread/1149386.aspx</link><pubDate>Thu, 22 Dec 2005 15:49:09 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1149386</guid><dc:creator>odin_dark</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1149386.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=1149386</wfw:commentRss><description>Ok, and how can i do that? i found some ImpersonationUtil, the code is the next, but it doesn't work&lt;br /&gt;
&lt;br /&gt;
public class ImpersonationUtil {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public static bool Impersonate( string logon, string password, string domain ) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsIdentity tempWindowsIdentity;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr token = IntPtr.Zero;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr tokenDuplicate = IntPtr.Zero;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if( LogonUser( logon, domain, password, LOGON32_LOGON_INTERACTIVE, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LOGON32_PROVIDER_DEFAULT, ref token) != 0 ) {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( DuplicateToken( token, 2, ref tokenDuplicate )
!= 0 ) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tempWindowsIdentity = new
WindowsIdentity(tokenDuplicate);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; impersonationContext =
tempWindowsIdentity.Impersonate();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if ( null != impersonationContext
) return true;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public static void UnImpersonate() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; impersonationContext.Undo();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [DllImport("advapi32.dll", CharSet=CharSet.Auto)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public static extern int LogonUser( &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; string lpszUserName, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String lpszDomain,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String lpszPassword,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int dwLogonType, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int dwLogonProvider,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ref IntPtr phToken );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [DllImport("advapi32.dll",
CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public extern static int DuplicateToken(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr hToken, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int impersonationLevel,&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ref IntPtr hNewToken );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; private const int LOGON32_LOGON_INTERACTIVE = 2;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; private const int LOGON32_LOGON_NETWORK_CLEARTEXT = 4;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; private const int LOGON32_PROVIDER_DEFAULT = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; private static WindowsImpersonationContext impersonationContext; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: Check services on remote machine</title><link>http://forums.asp.net/thread/1149085.aspx</link><pubDate>Thu, 22 Dec 2005 09:10:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1149085</guid><dc:creator>David Banister</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1149085.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=1149085</wfw:commentRss><description>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.</description></item><item><title>Check services on remote machine</title><link>http://forums.asp.net/thread/1147780.aspx</link><pubDate>Tue, 20 Dec 2005 22:27:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1147780</guid><dc:creator>odin_dark</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1147780.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=25&amp;PostID=1147780</wfw:commentRss><description>&lt;p&gt;Hello, I'm trying to check the services status on a remote machine,&amp;nbsp;the code i'm using is the next:&lt;/p&gt;&lt;font size=2&gt;
&lt;p&gt;string MachineName = "somename"&lt;/p&gt;
&lt;p&gt;ServiceController[] services = ServiceController.GetServices( MachineName );&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;foreach&lt;/font&gt;&lt;font size=2&gt;( ServiceController service &lt;/font&gt;&lt;font color=#0000ff size=2&gt;in&lt;/font&gt;&lt;font size=2&gt; services ) {
&lt;p&gt;&lt;font color=#0000ff size=2&gt;Console.Write(string&lt;/font&gt;&lt;font size=2&gt;.Format( "{0} [ {1} ]", service.ServiceName, service.Status.ToString() ) );
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;font face=Arial&gt;System.InvalidOperationException: Cannot open Service Control Manager on computer 'somename'. This operation might require other privileges.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Someone can help???&lt;/p&gt;
&lt;p&gt;&lt;font face=Arial&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font face=Arial&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;</description></item></channel></rss>