With the absence of any ADSI interface for PHP (and a COM implementation
that seems dodgy, at least for me and the others that have tried it), I'd
sort of given up thinking about using PHP for IIS manipulation and had
resigned myself to a fate of VBScript for anything I needed to do. 

I'd noticed there's a DLL that comes with the latest distribs of PHP called
php_iisfunc.dll, which I'd always wondered what it did. Whilst looking at
the zend.com site today, I found a list of undocumented functions
(http://www.zend.com/phpfunc/nodoku.php), which makes reference to these
functions. 

Because noone has done it yet (unless I've missed it) I thought I'd just
spam some quick information about some testing I did with them. 

----------------

string iis_GetScriptMap(string id, string virtualPath, string extension)

Returns IIS script mappings for a site. 

eg: 
  echo iis_GetScriptMap(iis_GetServerByComment("srvName"), "", ".asp");
returns: 
  .asp,F:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE

----------------

int iis_AddServer(string Path, string Comment, string ServerIP, int
ServerPort, string HostName, int ServerRights, int StartServer)

Adds a server to the IIS Metabase with the supplied parameters.

eg: 
  iis_AddServer("f:\\", "comment","130.102.1.1", 80,"hostname", 0,1);

Creates a new server with a hostheader name "hostname". Returns the Server
Instance ID for the created server. 

----------------

int iis_GetServerByComment(string comment);
int iis_GetServerByPath(string path);

Returns the server instance ID for the server with the comment (ie, the name
that appears in MMC). This ID can then be passed to some of the other
functions (as done below). 

eg:
  iis_GetServerByComment("Default Web Site");
  iis_GetServerByPath("f:\inetpub\wwwroot");
Returns: 
  Using 'Default Web Site' as the comment should return 1. 



----------------

int iis_StopServer(int serverID);

Stops a particular server

eg: 
  iis_StopServer("Default Web Site");
Returns
  1 on success, 0 on failure, I _think_ - however, I couldn't get this
function to work. 

I'm not sure of the difference between this one and iis_StopService. I would
have thought StopService would stop the whole webservice, but it seems to
take a serverID parameter. Shrug. 

----------------

int iis_StartServer(int serverID);

Starts a particular server

eg: 
  iis_StartServer("Default Web Site");
Returns
  1 on success, 0 on failure, I _think_. That is, the function returned 1 on
one site that I'd stopped, and successfully restarted it. However, I
couldn't make it restart the 'Default Web Site', yet it still returned 1.
Shrug. 

----------------

int iis_RemoveServer(int serverID);

eg: 
  iis_RemoveServer(iis_GetServerByComment("comment"));
Returns
  1 on success, -602 on failure (if I made up a fake comment)

----------------

There are also the following, which return values that I didn't try to
figure out (laziness), and take a 2nd parameter (referred to in the source
as string VirtualPath) that I also didn't figure out (also laziness):

iis_getdirsecurity(iis_GetServerByComment("website"), "");
iis_GetServerRight(iis_GetServerByComment("website"), "");
iis_GetServiceState(iis_GetServerByComment("website"));

Sorry about the poor documentation, but its better than what is on the PHP
site :)

I'm not sure how stable/reliable these are. I had a quick look through the
source but I'm not familiar enough with the metabase functions that are used
to know whether or not its done in the most stable way. I know though that
I've had enough problems with metabase corruption on servers that have only
ever been administered through MMC to be wary when trying 3rd party products
to do a similar thing. 

--dave

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to