Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to connect to MSSQL with PHP through a firewall

Status
Not open for further replies.

whiplashdomain

Programmer
Joined
Jan 30, 2004
Messages
4
Location
US
(note: This thread is currently also in the php-db mailing list right now. I'm just trying to see if anyone else has any solutions elsewhere.)

I've got an odd little problem that I just can't figure out. First, let me briefly describe my setup:

* Behind a firewall is a Windows 2003 Server running SQL Server 2000 with mixed mode authentication
* On that same internal network is a Linux web server with Apache 2, PHP 4.3.4, FreeTDS, etc.
* The firewall is setup to only allow the external web servers access to specific NAT forwarded ports (1433 TCP, 1434 UDP, 445 TCP)
* At a colocation ISP is another web server running Windows 2000 Server with Apache 2, PHP 4.3.3, etc.

I've written a script that connects to the SQL server for simple authentication and tracking. This script was developed on the internal Linux box. Everything works fine on this server: connecting, authenticating, queries, etc.

Running the same script on the external Windows box isn't working as well, though. Apache and PHP run just fine on this box with other scripts, but connecting to the SQL server through the firewall with the same script and settings, except for the IP address of the server (since we are connecting to the firewall's NAT'd ports), but I consistantly receive the following error:

Login failed for user 'JoeShmoe'. Reason: Not associated with a trusted SQL Server connection.

I'm thinking either there is a problem with the SQL server's settings somewhere, I don't know), or PHP on the external webserver, but I'm not sure what to do. I've looked all over the configurations for both servers and they look fine, checked several sites and lists for advice and couldn't find anything that would work.

Any ideas as to what I should be looking for?
 
I'm a bit confused. Let me see if I have this right.

You have a LAMP box and a MSSQL box inside your LAN, which is on a non-routeable network.

You have a WAMP box at another location.

Your firewall has been configured to NAT certain ports from the external WAMP box to your MSSQL box.

Your LAMP box can connect to your internal MSSQL, but the external WAMP box cannot.


Have you verified that on your external WAMP box PHP's MSSQL connectivity functions are working?


Want the best answers? Ask the best questions: TANSTAAFL!!
 
You're correct. I'm not 100% sure the mssql functions are working properly because I've yet to successfully connect and run queries. :| I do know what I've done so far to attempt to get it to work:

* Downloaded and installed the PHP 4.3.3 zip package from php.net (the one compiled with many extensions)
* Enabled the mssql extension in php.ini
* Copied the mssql extension dll to c:\winnt\system32\, along with ntwdblib.dll

I haven't installed the Client Tools (except for the ntwdblib.dll file) because of a problem locating a decent sized installer. I'm having to upload an entire CD of SQL Server 2000 because I can't locate an installer for just the Client Tools. :|
 
Okay, it appears that the Client Tools absolutely -must- be installed, which somewhat contradicts the PHP manual < It said you could either copy the ntwdblib.dll from the SQL server to the one running PHP, or install the Client Tools.

It does appear to be extremely sluggish, though. I'm running over a T1, so a simple query shouldn't take this long (about 5-10 seconds externally, less than a second internally).
 
One more reason to bring this stuff in-house, I suppose. :
Thanks for your help. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top