Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!!

Posted (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 by Derek Stone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...