Since the majority of the code we've demonstrated so far in this book has been written in VBScript, you may be wondering why we are going to talk about Visual Basic.NET (VB.NET). Unfortunately, one of the drawbacks with the .NET Framework is that it currently does not provide native support for VBScript. It does support JScript, but since Visual Basic is a much more powerful language than JScript, we will use VB.NET in our examples. It is still unclear what Microsoft's future direction is in regard to providing native support for scripting languages like VBScript in .NET. Until that happens, you should get more familiar with the .NET class library and gain some experience with Visual Basic, which will ultimately increase your capabilities as a programmer. As we mentioned earlier, one of the design goals for the .NET Framework was simplicity. With the .NET Framework class library, Microsoft has made developing Windows-based applications significantly easier. As far as Active Directory goes, it will not take long at all to map your ADSI knowledge to the classes, properties, and methods in the System.DirectoryServices namespace.
To get started using VB.NET, you'll need to get an integrated development environment (IDE) such as Visual Studio.NET (VS.NET), which is available from http://msdn.microsoft.com/vstudio/. Once you have VS.NET, you should download the latest .NET Framework SDK, which is available from http://msdn.microsoft.com/netframework/. Once you have both of those installed, you are ready to start programming with the .NET Framework.
To start a new project in VS.NET, select File New Project from the menu. At that point you'll see a screen similar to the one in Figure 28-1.
Click on Visual Basic Projects and select Console Application from the Templates window. Now you have started a new project and are ready to start writing code in a file called Module1.vb, which contains the following code by default:
Module Module1 Sub Main( ) End Sub End Module
If you are inexperienced with VB, you can create usable programs simply by adding code to the Main( ) subroutine. Once you become more experienced, you can start creating your own classes, subroutines and functions, and reference them within Main( ).
To start using the System.DirectoryServices classes to query and manipulate Active Directory, you must add a reference to it in your project. From the menu, select Project Add Reference, then under Component Name click on System.DirectoryServices. Click the Select button and click OK. Figure 28-2 shows what this window looks like in VS.NET.
You are now ready to start writing Active Directory applications with the .NET Framework, so let's take a look at the System.DirectoryServices namespace.