开发者

RPC Error while trying to access IIS

开发者 https://www.devze.com 2023-03-12 17:29 出处:网络
I am trying to get list of IIS services running on a remote server, the problem is that if i try accessing a server other than my localhost I get a RPC error and hence unable to retrieve data! The cod

I am trying to get list of IIS services running on a remote server, the problem is that if i try accessing a server other than my localhost I get a RPC error and hence unable to retrieve data! The code that I am using righ开发者_如何学Pythont now is:

         try
        {
            string s = null;
            Hos = Hos.Trim();
            DirectoryEntry IIS = new DirectoryEntry("IIS://" + Hos + "/w3svc/1/root", "username", "password");
            foreach (DirectoryEntry de in IIS.Children)
            {
                if (de.Children.ToString() != null)
                {
                    s += de.Name.ToString() + "\n";
                }
            }

            return s;
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error in EnumerateWebsites: " + ex.Message);
            return null;
        }

I return the string and display in a TextBlock, anyway it is working fine on local systems, if i take the .exe and run it on a diff comp then it is able to retrieve the IIS services in that computer too. But remote access is not working ..


it was actually pretty stupid. I just had to remove the username and password because my organization works on windows authentication. Anyhoo now I am able to retrieve the information from any computer on which I have been assigned a administrator.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号