Posts tagged ‘Windows’

Sharing Files with Windows from Ubuntu Karmic

We got a desktop running Windows 7 over the Christmas holidays. I hadn’t been faced with the prospect of sharing files with it up until I wanted to play an MP3 file located on my laptop — which is running Ubuntu — from the desktop, which is connected to a better speaker system. As it turns out, sharing files with Windows from Ubuntu has gotten a lot easier with Ubuntu 9.10 Karmic Koala.

Open Nautilus and navigate to the parent directory of the one you’d like to share. Right-click on that directory and select the option “Sharing Options.” In the window that appears, check “Share this folder.” If Samba is not already installed on your system, this will prompt you to install it. The nice thing is that it handles all the interaction with APT and configuration of user accounts and shares for you versus the manual approach that’s been required in the past.

Once the service is installed, if you’d like to share the directory with users without requiring them to enter user credentials, check the box “Guest access.” Finally, click the “Create Share” button. You’ll receive a prompt to restart your session so the setting changes can take effect; go ahead and do this.

When I tried to access the directory from the Windows 7 desktop at this point, I still got prompted for credentials. I tried manually rebooting my laptop and at that point was able to access the files anonymously without further issue. I don’t know if a manual restart is always required, but it did the trick for me.

Hope this helps someone!

PHP 5.2 and SQL Server 2000 on Windows XP

Recently at work, I was tasked with finding a method to retrieve data from a third-party SQL Server 2000-based system into our own MySQL-based application. It’s worth noting that both system are behind their own firewalls and I was trying to bear security in mind as I did this.

First, I had to actually get into the system with the SQL Server database. For this, I used Citrix GoToAssist. The company behind the software makes their money off of hosting the servers it uses and selling access to them as a service. The client software uses HTTPS for security and to get around firewall configurations. While their software is nice, I’d be interested to see if anyone knows of any OSS equivalents of it.

Once I had access to the system, I needed something akin to phpMyAdmin or Oracle SQL Developer in order to see what resources were available on the SQL Server itself. For that, I found a local copy of EMS SQL Manager already on the system. This wasn’t the most full-fledged product I’d seen for this type of purpose, but it was free, included everything I needed, and did the job in a pinch.

After doing some reconnaisance on the database structure using the information that had been given to me by the third-party vendor, I downloaded the ZIP archive containing the standard build of PHP 5.2 for Windows. Side note: one of the things I like about PHP on Windows is that, for CLI purposes, it only takes decompressing the ZIP archive, tweaking the configuration file to get the settings and extensions you want, and executing the binary to get it up and running.

With my SQL Server experience being dated by about six years, I started throwing PHP code at the system to see what would stick. I noticed that the server was already set up to accept trusted connections, and being that I was running the script on the local system, this made it likely that authentication wouldn’t present any issues, or so I thought.

I created my PDO instance like so:

$db = new PDO('mssql:localhost;dbname=...');

And then attempted to call a particular stored procedure that I’d been told would have some of the data I was looking to extract. I was surprised to get this in response when calling PDO::errorInfo().

Array
(
[0] => HY000
[1] => 10007
[2] => Could not find stored procedure ... [10007] (severity 5)
[EXEC ...]
[3] => -1
[4] => 5
)

Now I had just been in EMS SQL Manager and seen the stored procedure myself, so I knew it was there. I tried using the sa account, but that didn’t seem to work either. After some digging, I found that I had to create an account for the current Windows user on the current network domain in order to make PHP capable of seeing the stored procedure when using a trusted connection. Once I’d created the account and given it access to execute the specific stored procedure I was trying to call, I tried again and PDO::errorInfo then gave me this.

Array
(
[0] => HY000
[1] => 10007
[2] => Unicode data in a Unicode-only collation or ntext data
cannot be sent to clients using DB-Library (such as ISQL) or
ODBC version 3.7 or earlier. [10007] (severity 5) [EXEC ...]
[3] => -1
[4] => 5
)

Apparently there are issues with the MS SQL stand-alone PHP extension and SQL Servers using unicode collation. Some more digging turned up that the only way to get around this was to use ODBC. Once I did that, I found that I was no longer getting an error when trying to call the stored procedure.

$db = new PDO('odbc:Driver={SQL Server};Server=localhost;
Database=...;Trusted_Connection=yes;');

Though I knew of stored procedures conceptually, my previous experience with SQL Server had never included using them. As such, I wasn’t familiar with the syntax and came across something rather strange while trying to troubleshoot it: if the arguments to a stored procedure are surrounded by parentheses in the  query calling that stored procedure, the code silently fails and returns no results.

// $stmt = $db->prepare('EXEC ...(?, ?)'); // Fails silently
$stmt = $db->prepare('EXEC ... ?, ?'); // Works as expected

Last on the list of “interesting things I experienced” while on this little trek wasn’t related to the database, but to what was happening when I attempted to push data from the SQL Server machine to our LAMP machine. I was using the PHP serialize() function to encode the data into a string, then using the streams HTTPS wrapper to send it via a POST request to a PHP file on the LAMP machine. This meant I wouldn’t have to poke a hole in the firewall on either side since both were already open to web traffic. When attempting to run the code for this, I got an error on the client side:

PHP Warning:  file_get_contents(): SSL: An existing connection 
was forcibly closed by the remote host.
PHP Warning: file_get_contents(https://...): failed to open
stream: HTTP request failed!

The cause for this wasn’t immediately apparent. Upon checking Apache error logs, I came across this:

PHP Fatal error:  Allowed memory size of 16777216 bytes 
exhausted (tried to allocate 3381676 bytes)

The actual issue had to do with how much data I was trying to send; it was exceeding the value specified in the memory_limit configuration setting, which as it turned out was set to the recommended value for a significantly older version of PHP. After updating it to a more current recommended value and bouncing Apache, all was well.

Hope the details of my experiences prove helpful to someone else. Thanks to those who provided assistance along the way.

Dual-Booting XP and Kubuntu on a Sony Vaio

So it turns out the Holy Grail, Promised Land, or whatever you want to call it, does exist after all. After a number of different approaches and attempts, I finally got my Sony Vaio VGN-NR298E dual-booting Kubuntu and Windows XP. The solution turned out to be a well-known one: nLite.

With it, I was able to not only roll the drivers for my SATA drive into a custom XP CD, but also SP2 as well. It also offers options to include other drivers as well as post-SP2 Windows hotfixes and custom configuration options. I have to give major kudos to the nLite folks, as I imagine I would have given up at attempting to do this had it not worked as splendidly as it did.

So, without further ado, here’s the final recipe for succes in this endeavor. Obligatory disclaimer: I take no responsibility should you not have the same success or suffer damages by following these instructions. Other obligatory disclaimer: The only reason I went to this much trouble to dual-boot to XP is because I can’t find another solution that allows me to play my games.

  1. Download nLite. Use it to make a local copy your Windows XP CD.
  2. Download the standalone Service Pack 2 installer. Point nLite to it as a service pack to include.
  3. Download the Intel 82801HEM/HBM SATA AHCI Controller driversExtract them for unattended installation and point nLite to them.
  4. At this point, you can choose other drivers to include on the CD. Below is a list of those that are relevant to the Vaio. Be sure to have either Ethernet or Wifi drivers included in the CD or on a storage medium that Windows can recognize natively without external drivers.
  5. I ran into a small issue at this point that may or may not be pertinent to your case: the only machine on which I had a CD burner available was a Linux server machine. nLite was helpful in this regard, though, and offered an option to make the ISO file it created mkisofs-compatible. Using this, I was able to copy the ISO over the network to the Linux server, use mkisofs to test it and cdrecord (man page examples on this utility are helpful) to burn it.
  6. Boot the custom CD. Note that you no longer have to hit F6 at the point where you normally would to install custom drivers; the installer will simply detect that they’re available on the CD and load them from there. Installation should be pretty normal after this point. Partition your drive however you like, being sure to leave enough room for Kubuntu to load. You’ll probably notice the installer forces you to leave 8 MB free, presumably for the NT boot loader. Once you’re in Windows, you can reset your screen resolution and manually install any drivers you didn’t roll into the CD. Once you’re connected, install any further Windows updates that might be necessary.
  7. Once XP is set up to your liking, pop the Kubuntu CD in, boot from it, and access the installer on the desktop once KDE has loaded. In order to not have Kubuntu overwrite your XP installation, you’ll have to opt to partition manually. You’ll notice that the installer sees the 8 MB that XP made you reserve earlier. I’m not sure why, but the installer sees this as free space. At any rate, I just consolidated that space into the Kubuntu partition and let it set aside its 3 MB to load GRUB. I’m not sure how to keep the NT boot loader and not load GRUB, so if you prefer that route, you’ll have to dig around on your own to find out how. Set up your root and swap partitions and continue.
  8. Installation should again proceed fairly normally. Once you’ve loaded your installation for the first time, connect your machine to an ethernet cable and launch Adept, the package manager GUI for Kubuntu. Do a search for Windows and you should find a package called Windows Wireless Drivers. Install this for wireless if you need it. Beyond that, install updates and you should be good to go.

And that’s all there is to it, folks. It was a wild ride to figuring out the process, so I hope my efforts help someone else looking to do the same thing. Cheers!