Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Friday, May 25, 2012

Setting LDAP parameter to invalid value caused strange error

I was working on a web based application using C# and ran into a bit of a strange error.  I'm using an LDAP to try and set the option "Require user to change password at next login"  for an Active Directory account.  A small typo resulted in a strange error that lead me to waste some time today.  Thought I'd share to hopefully prevent others from having the same issue.  The error I received was:


A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)

The snippet of relevant code:


    public bool RequireUserToChangePwd(bool force)
    {
        bool success = false;

        try
        {
            DirectoryEntry user = loadSpecificEntry();
                
            if (user != null)
            {
                if (force)
                    user.Properties["pwdLastSet"].Value = 0;
                else
                    user.Properties["pwdLastSet"].Value = 1;
                        
                user.CommitChanges();
                user.Close();
                success = true;
            }
        }
        catch (Exception ex)
        {
            tossFormattedExceptionMessage("Unhandled error requiring force password change",ex);
        }

        return success;
    }


The exception was happening on the call to CommitChanges();   It was happening because the "pwdLastSet" property only has two valid values  0  and  -1  so when I called this method with force = false the exception was being tossed.   Needless to say the error message "A device attached to the system is not functioning" is a bit misleading.   Changing the code to supply the proper value of -1 resolved the issue.  I imagine this error could potentially show up in when using invalid values for other properties being modified using LDAP.  If you're reading this, hopefully I've saved you some time.

References
https://groups.google.com/forum/?fromgroups#!topic/microsoft.public.adsi.general/qUfqhn0qb6M

Thursday, November 25, 2010

Capistrano deploy from Windows failing in transfer.rb

I recently ran into an issue with deploying from Windows using Capistrano.  The project I was using had been setup as a multi-staged deployment with Capistrano and had been working quite nicely deploying to my staging and production environments.  Unfortunately, the project sat for a few months and collected some dust while I was busy earning a living.  When I finally got around to working on it again I discovered that capistrano was now failing on the deploy command.  The error I was getting looked liked this:

capistrano/transfer.rb:156
C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:156:in `[]=': undefined method `[]=' fo
r nil:NilClass (NoMethodError)
        from C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:207:in `handle_error'
        from C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:48:in `process!'
        from C:/Ruby1.8.7/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:43:in `loop'

 
Although not completely obvious, the clue to the failure is in the location of the failure.  Failed in capistrano in transfer.rb and it's failing there because tar didn't execute and therefore didn't create the archive file to transfer to the server.


I truly love that when capistrano runs it identifies each command it's going to execute so you can see what it's trying to do.  I'm sure it would have been a much longer trouble shooting session if I had to dig through source to figure that out instead of it just telling me.  When I received that error, knowing that it was working fine a few months ago, it was obvious to me that I had made some changes to my environment that introduced the problem.  As it turns out, I was missing unix utilities in my PATH and in particular I was missing tar.  Once I added a path to my Cygwin/bin folder to my PATH everything started working again. 

Hope this helps someone avoid a few minutes of trouble shooting.

Saturday, November 6, 2010

Upgrade Windows 2008 Standard to 2008 Enterprise

I've recently needed to upgrade Windows Server 2008 Standard Edition to Server 2008 Enterprise Edition to take advantage of additional memory on the server. I'm running the 32 bit version OS not the 64 bit. The 32 bit of Windows 2008 Standard only supports up to 4 GB of memory but the Enterprise Edition will handle up to 64 GB. (memory limits MSDN)  All the documentation I could find (blog posts, MSDN, TechEd, etc) suggested that the upgrade could be done in place but that there were some considerations depending on certain roles the server plays.  Fortunately my server didn't fall into any of those special circumstances.  However, when I ran the install and selected Enterprise Edition I received the message:

"Upgrade has been disabled.
The upgrade can not be started.  To upgrade, cancel the installation and then choose to upgrade to a version of Windows that is more recent than the version you are currently running."

and the button I would use to perform the upgrade in place was disabled.  Naturally I was a bit confused since my current installation was Windows 2008 Standard Edition SP2 and I'm trying to upgrade from Enterprise Edition 2008 SP2.

After a bit more digging on Google I found this blog post (Thanks Network Steve) that suggested that maybe SP2 was the issue causing the button to be disabled. So, not feeling very good about this approach, but with no other real options, I decided to go for it.  After making all the necessary backups I uninstalled the service pack. Yes, the OS still booted and seemed to work and fortunately for me this actually solved the issue with the installer.  I was able to do the upgrade in place from Standard to Enterprise Edition.

Hope this helps someone else!

Thursday, December 24, 2009

PuTTY with Ubuntu 9.10 and password less connections

A good friend of mine said I was not an advanced Linux user.  (He is.)  He was being kind to say the least as I consider myself somewhere between novice and intermediate if there is such a place. Compared to him I'm definitely novice. I was just struggling with a Linux server administration task today.  I was trying to secure my new VPS following Linode documentation (BTW, Linode has been great so far) for "Basic" security and ran into a bit of a snag while trying to lock down my use of SSH.  The trouble I ran into was with using RSA keys to authenticate my SSH connection with the server.  I wanted to disable the password option and setup SSH to use a public / private key pair.  The Linode documentation was helpful to a point but because I'm a Windows user it suggested that I use the PuTTY utilities to generate my keys and upload to the server.  Unfortunately I kept getting the message:

"No supported authentication methods available"

The documentation on PuTTY wasn't helpful and after several searches turned up a lot of wrong answers I finally found a post that suggested that Ubuntu 9.10 uses OpenSSH which relies on OpenSSL and that something was wrong or incompatible with that OpenSSL and would cause PuTTY problems. (I can't find the post again to reference, sorry) I turned on logging in PuTTY to see what I could see and sure enough, OpenSSH is being used.  I suppose there is a way to know that by looking on the server.  Going with that assumption I decided to generate the keys on the server and then download the private key for use with PuTTY on my Windows box.  Turns out that when I opened the id_rsa private key file with PuttyGen it was able to convert it to the "PuTTY" format for the file.  Couple seconds later I loaded into PageAnt and viola I was connecting to my server via SSH without using a password.

Moral of this story.  If you're using PuTTY to connect from Windows to an Ubuntu 9.10 server be sure to generate your keys on the server to save yourself some time and frustration.

References
Basic Security Settings (Linode Docs)
Linode VPS Hosting

Saturday, November 21, 2009

Installing Autotest and Snarl on Windows

I was looking for a personal productivity boost (no cracks about having Windows please) and I decided to setup Autotest. Unfortunately for me the best information I could find to do this was slightly more than a year old. To have the same reference point I did you can see the post Andrew On Rails: Autotest and Snarl - Coding bliss is obtainable in Windows.

Before you try to setup Autotest I recommend confirming your current suite of tests are actually working even if they aren't all passing.

As a reference my important version numbers are:

Ruby 1.8.6, Gem 1.3.5, and Rails 2.3.4

I have Windows XP Professional Version 2002 SP3 and a laptop with Windows Vista Home Premium SP2 and I followed these steps to get Autotest setup and working with Snarl on Windows.

  1. Start with downloading and installing the latest version of Snarl. At this time that's Snarl R2.21 (V40.15) I picked the default installation path.
  2. Next I installed ZenTest (4.1.4) (don't forget the capital Z and capital T). I noticed that there is an all lower case zentest with lots of dependencies. I didn't use that one.

    gem install ZenTest

  3. I also installed autotest-rails which was recently split from ZenTest. (version 4.1.0)

    gem install autotest-rails

  4. Then install ruby-snarl. (said version 1.0.0 on the install but shows 0.0.8 on the folder under gems)

    gem install ruby-snarl

  5. Now download and install the GNU Diffutils package. I used the complete package dated May 24, 2004. Autotest uses this to figure out which tests have changed so it can just re-run those particular tests. You will need to put the bin directory into your system PATH.
  6. While you are adding that bin directory to your system PATH you also need to setup a "HOME" environment variable and point it to some place real. I used HOME = %USERPROFILE%
  7. The default icons used with ruby-snarl are located under the gems folder. On my box that is "C:\ruby\lib\ruby\gems\1.8\gems\ruby-snarl-0.0.8\icons". You are probably going to want a couple of nice images because these defaults are small. One for tests have passed and one for tests failing. You can find a couple here: http://www.danielfischer.com/2007/05/14/ruby-on-rails-bdd-with-autotest-growl-rspec at the very bottom of the page. Whatever images you come up with you need to drop them into that icon folder and use the same names as the defaults. There's probably a better way to configure this but hey, I was in a hurry, that's why I wanted Autotest setup this way.
  8. Now create a file named .autotest in your Rails application root directory. You can't use the GUI to create an extension only file name so you'll probably want to drop to a command prompt and just type Edit .autotest to get this going. The only line you need to include in this file right now is:

    require "autosnarl"

  9. At this point you should be able to drop to a command prompt in your Rails application root directory and run the command "autotest". NOTE: If you have an open command prompt you'll need to exit it and open another so that you get the PATH and the HOME environment variable changes you made. Running the autotest command should result in your tests running and the result being shown as a Snarl message.

References

ZenTest

Why Autotest?