Apache, Networking, php, Windows

PHP and Windows Networking

Have you been annoyed when sometimes, you are asked to enter a username and password when accessing a network resource in a Windows network? It even asks password even when that machine does not set password for all of its users.

Since I’m developing PHP application (web based) for Windows most of the time, I need to handle this such annoying Windows bug or whatever you may call it. So we will discuss on how to handle this situation and with relation to our PHP application.

An Example – Network Printing

Assuming you have a PHP application that prints data to a network PC and not the server’s printer. To do that, PHP or shall we say, Apache, must have access to network resources. By default, Apache is limited only to the local resources. To access network resource, Apache must run as a local user and not as system user which is the default.

To run Apache as a local user, read this: Run Apache as Local User – Windows XP.

That way, Apache can now access the shared printer over the network. However, the Windows mysterious bug will intermittently give you problem. As mentioned above, there are times when you are asked a username and a password when accessing a shared resource on a Windows network. That will result on a failure to your PHP printing process.

To combat this issue, I did some trick:

The Trick

To get rid of the authentication (the asking of username and password) we just need our server to automatically supply the username and password. How do we do that?

Create a user on the client whose username and password is the same as the server. That way, our poor Apache will be able to use the printer and our PHP application will be happy.

Leave a reply

Your email address will not be published. Required fields are marked *