prowla2003 Posted February 3, 2004 Posted February 3, 2004 I'm using this code Dim oDE As System.DirectoryServices.DirectoryEntry Dim oDC As System.DirectoryServices.DirectoryEntries Dim sIISPath As String sIISPath = "IIS:\\localhost\W3SVC\1" oDE = New DirectoryServices.DirectoryEntry(sIISPath) oDC = oDE.Children and running it in in debug and using the Autos window to try and find a property somewhere that holds the port that the IIS service is running on and cant.. can someone help. please!! Quote
prowla2003 Posted February 5, 2004 Author Posted February 5, 2004 eerrrrrrr thanks for all your help!!!! Quote
prowla2003 Posted February 5, 2004 Author Posted February 5, 2004 (edited) the answer public string getWWWPort( string sPortType, string sWebSvcInstance) { string sw3Site = "IIS://localhost/" + sWebSvcInstance; //string sw3Schema = ""; string sTmp=""; string [] sTmpArray ; if (sPortType.ToUpper() == "SERVERBINDINGS" ) { sPortType = "ServerBindings"; } if (sPortType.ToUpper() == "SECUREBINDINGS" ) { sPortType = "SecureBindings"; } //DirectoryEntry iisWebSrv = new DirectoryEntry("IIS://localhost/W3SVC/4"); DirectoryEntry iisWebSrv = new DirectoryEntry(sw3Site); PropertyCollection iisWebSrvProperties = iisWebSrv.Properties; DirectoryEntry schema = new DirectoryEntry("IIS://localhost/schema/" + iisWebSrv.SchemaClassName); PropertyCollection schemaProperties = schema.Properties; foreach(string s in schemaProperties["OptionalProperties"]) { try { if( s == sPortType ) { sTmp = iisWebSrvProperties[s].Value.ToString(); sTmpArray = sTmp.Split(new Char [] {':'}); sTmp = sTmpArray[1]; } } catch(Exception ex) { Console.WriteLine(ex.Message); } } return sTmp; } Edited February 5, 2004 by Derek Stone Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.