Please help me!
I have reviewed about 100 source pages.
I just could not do it.
I work 2 days.
My last point is creating a Binding.
I'm getting an "Access Denied" error.
[TR] Yaklasik 100 kaynak sayfa inceledim.
Bir türlü yapamadim.
2 gündür ugrasiyorum.
Son geldigim nokta Binding olusturma.
"Access Denied" hatasi aliyorum.
- public void Creator()
- {
-
- string hostName = "BuBirSitedir";
- string domainName = "www.bubirsitedir.com";
-
- ConnectionOptions options = new ConnectionOptions();
- options.Impersonation = System.Management.ImpersonationLevel.Impersonate;
- options.Authentication = AuthenticationLevel.Connect;
- options.EnablePrivileges = true;
- options.Impersonation = ImpersonationLevel.Default;
-
- ManagementClass classInstance = new ManagementClass("root\\WebAdministration", "Site", null);
-
- ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\MicrosoftIISV2", "DESKTOP-MGA1F3C"), options);
- scope.Connect();
-
- ManagementBaseObject[] serverBindings = new ManagementBaseObject[3];
- serverBindings[0] = CreateServerBinding(scope, string.Format("{0}", hostName, domainName), "127.0.0.1", 40804);
- serverBindings[1] = CreateServerBinding(scope, string.Format("30603", hostName, domainName), "127.0.0.1", 30603);
- serverBindings[2] = CreateServerBinding(scope, string.Format("127.0.0.1", hostName, domainName), "127.0.0.1", 20402);
- }
-
-
- private static ManagementObject CreateServerBinding(ManagementScope scope, string hostName, string ip, int port)
- {
- ManagementClass mc = new ManagementClass(scope, new ManagementPath("ServerBinding"), null);
- ManagementObject mco = mc.CreateInstance();
- mco.Properties["Hostname"].Value = hostName;
- mco.Properties["IP"].Value = ip;
- mco.Properties["Port"].Value = port;
- mco.Put();
- return mco;
- }