Code Generation Using T4 and VS 2010

by Ray 19. July 2010 07:00
[No text]

Tags:

Programmatically Authenticating Users Using ADAM

by Ray 3. July 2010 13:50

Recently I was attempting to migrate an application from Java to .NET that leveraged ADAM as it’s user store. On first look you think, “No problem, .NET comes with an Active Directory Provider, this should be easy.” For me this wasn’t the case, a slew of problems eventually had me looking at a way to do the authentication myself.  After doing some Binging I finally came across a very interesting site that was completly dedicated to programming .NET applications with Active Directory here<

Here is the process that I went through to do this, this is assuming that you have ADAM already installed and configured on a machine somewhere.

.NET Comes with two namespaces that are essential when working with Active Directory, System.DirectoryServices which will be referred to as SDS and System.DirectoryServices.Protocols which will be referred to as SDS.P.

In order to streamline the process I created an Authentication class that I could call throughout my application:

 /// <summary> 
     /// Contains methods used to authenticate users 
     /// </summary> 
     public  class  Authentication 
     {
         /// <summary> 
         /// Gets or sets the path. 
         /// </summary> 
         /// <value>The path.</value> 
         public  string  Path { get ; set ; }
         /// <summary> 
         /// Gets or sets the filter attribute. 
         /// </summary> 
         /// <value>The filter attribute.</value> 
         public  string  FilterAttribute { get ; set ; }
 
         /// <summary> 
         /// Initializes a new instance of the <see cref="Authentication"/> class. 
         /// </summary> 
         /// <param name="path">The path.</param> 
         public  Authentication(string  path)
         {
             Path = path;
         }
 
         /// <summary> 
         /// Authenticates the user. 
         /// </summary> 
         /// <param name="username">The username of the user you are trying to authenticate.</param> 
         /// <param name="password">The password of the user you are trying to authenticate.</param> 
         /// <returns>true if authenticated otherwise dalse</returns> 
         public  bool  AuthenticateUser(string  username, string  password)
         {
             //Create a connection to the ldap server you want to authenticate against 
             LdapConnection  connection = new  LdapConnection (Path);
 
             //These options do not need to be set and are specific to the environment 
             var  ldapSessionOptions = connection.SessionOptions;
             ldapSessionOptions.ProtocolVersion = 3;
             ldapSessionOptions.SecureSocketLayer = true ;
 
             connection.AuthType = AuthType .Basic;
 
             //Set our connection credentials to our supplied username and password. 
             NetworkCredential  credential = new  NetworkCredential (username, password);
             connection.Credential = credential;
 
             try 
             {
                 //Check if the credentials are valid.  If they are not, the ldap connection will not bind. 
                 connection.Bind();
             }
             catch (Exception  ex)
             {
                 throw  new  Exception (ex.ToString());
             }
 
             return  true ;
         }
     }
 

Now when you want to authenticate, you just instantiate the class and then call the AuthenticateUser method supplying the username and password.

How to configure XAMPP to Start Automatically in OpenSUSE 11.3 with Gnome

by Ray 18. May 2010 02:14

First and foremost, I’d like to say I’ve been a Microsoft guy all my life. With that said, I am not so closed minded that I don’t realize that there are other solutions and technologies other than those supported by Microsoft. Recently I’ve been getting into the LAMP space for three main reasons. The first is that I had a need to generate income outside of my current job and far and away PHP is the big web technology for the customers I want to target. Secondly it’s free. Thirdly there seems to be a wealth of information about pretty much everything.

The other day I downloaded openSUSE 11.3 and the newest version of XAMPP to go ahead and kick off the learning process and boy was I surprised at how easy it was to get everything installed and up and running. Satisfied with my progress I turned my VM off and went off to dreamland.

The next morning I woke up, booted up my VM to start playing with my new toy, and realized that XAMPP was not running and actually needed to be started manually each time. This was not an acceptable for me so I went and found the solution to this problem via the XAMPP FAQ and a few other sites. Listed below are the steps in which I took.

  1. Navigate to GNOME Terminal by clicking on Computer and then selecting More Applications. On the left hand side of the Application Browser, type in Gnome Terminal and then press enter. This will start gnome Terminal.

    01
  2. Within the command prompt type the following command line in to get your current runlevel, egrep :initdefault: /etc/inittab/. This will return your runlevel in the format id: (x) : initdefault: where (x) is your runlevel. In most cases this number should be either 3 or 5. Both runlevel’s represent multi-user modes the difference between the two is that a runlevel of 3 means that only console logins are being used while a runlevel of 5 means that you are leveraging the display manager.

    01
  3. Now that you have your run level, type the following within the command prompt: cd /etec/rc.d/rc(x).d where (x) is your runlevel from the previous step. Next create a symbolic link with the following entry, ln –s /opt/lampp/lampp /etc/inti.d/lamp
  4. The final step is to activate the symbolic link that you just created. There are two ways in which you can do this, you can either use YaST or for the hardcore guys out there you can use the chkconfig command. Being that I’m a Linux newbie, I chose to do this with YaST. Open YaST by clicking the computer button and then selecting it from the menu on the right hand side of the computer pop up screen. If you are not logged on as a super user, you will be asked to provide credentials.

    01
  5. Within the YaST Control Center window type in run within the filter box and then press enter, this will start the Systems Services application.

    01
  6. Scroll down until you find the entry for lamp. Left click the entry and then click the enable button at the bottom of the system services Window.

    01
  7. Close out all YaST windows, YaST will save the configuration settings that you just made upon exit. Your XAMPP installation will now run automatically upon boot.

Tags: , , , ,

XAMPP | OpenSUSE | Gnome