using System; using System.Collections.Generic; using System.Text; using System.Runtime.CompilerServices; using Microsoft.VisualBasic.CompilerServices; using Microsoft.VisualBasic; using System.Collections; namespace IISInstallerHelper { public class IISHelper { public void Install(string strVDir, string strPort) { try { int num = this.FindServerNum(strPort); string strFullObjectPath = "IIS://" + Environment.MachineName + "/W3SVC/" + num.ToString() + "/ROOT/" + strVDir; object o = RuntimeHelpers.GetObjectValue(this.GetIISObject(strFullObjectPath)); LateBinding.LateSet(o, null, "AuthAnonymous", new object[] {false}, null); LateBinding.LateCall(o, null, "SetInfo", new object[0], null, null); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Information.Err().Raise(0x270f, "something", exception.Message, null, null); ProjectData.ClearProjectError(); } } private object GetIISObject(string strFullObjectPath) { object objectValue=null; try { objectValue = RuntimeHelpers.GetObjectValue(Interaction.GetObject(strFullObjectPath, null)); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Information.Err().Raise(0x270f, "GetIISObject", "Error opening: " + strFullObjectPath + ". " + exception.Message, null, null); ProjectData.ClearProjectError(); } return objectValue; } public int FindServerNum(string strPort) { int num=0; IEnumerator enumerator=null; Collection collection = new Collection(); string machineName = Environment.MachineName; string strFullObjectPath = "IIS://" + machineName + "/W3SVC"; object o = RuntimeHelpers.GetObjectValue(this.GetIISObject(strFullObjectPath)); try { enumerator = ((IEnumerable)o).GetEnumerator(); while (enumerator.MoveNext()) { string str = StringType.FromObject(LateBinding.LateGet(RuntimeHelpers.GetObjectValue(enumerator.Current), null, "AdsPath", new object[0], null, null)); str = Strings.Right(str, Strings.Len(str) - Strings.InStrRev(str, "/", -1, CompareMethod.Binary)); try { int item = IntegerType.FromString(str); collection.Add(item, null, null, null); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); ProjectData.ClearProjectError(); } } } finally { if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } for (int i = collection.Count; i >= 1; i += -1) { strFullObjectPath = StringType.FromObject(ObjectType.StrCatObj("IIS://" + machineName + "/W3SVC/", collection[i])); o = RuntimeHelpers.GetObjectValue(this.GetIISObject(strFullObjectPath)); Array array = (Array)LateBinding.LateGet(o, null, "ServerBindings", new object[0], null, null); string text4 = StringType.FromObject(LateBinding.LateIndexGet(array, new object[] { 0 }, null)); string text5 = Strings.Left(text4, Strings.InStrRev(text4, ":", -1, CompareMethod.Binary) - 1); text5 = Strings.Right(text5, Strings.Len(text5) - Strings.InStr(text5, ":", CompareMethod.Binary)); if (StringType.StrCmp(strPort, text5, false) == 0) { if (ObjectType.ObjTst(LateBinding.LateGet(o, null, "ServerState", new object[0], null, null), 2, false) == 0) { return IntegerType.FromObject(collection[i]); } } else { collection.Remove(i); } } switch (collection.Count) { case 0: Information.Err().Raise(0x270f, "FindServerNum", "No Active Servers with the requested port were found. Port=" + strPort + ". ", null, null); return num; case 1: return IntegerType.FromObject(collection[1]); } Information.Err().Raise(0x270f, "FindServerNum", "More than one Active servers with the requested port were found. Port=" + strPort + ". ", null, null); return num; } } }