A colleage approached me and asked how he could convert some ASP Classic code to ASP.Net 2.
Here's the snippet
Dim user 'DOMAIN\USERNAME
Const DomainAuthority = "dc.hq.domain.com"
user = Request.ServerVariables("AUTH_USER") ' BASIC Authentication
user = Mid(user, InStr(user, "\") + 1)
Set user = GetObject("WINNT://" & DomainAuthority & "/" & user)
For Each grp in user.Groups
If grp.Name = "GroupName1" Then GroupFlag1 = True
If grp.Name = "GroupName2" Then GroupFlag2 = True
Next
This doesn't compile in a VB.Net web-app.
In order to fix this, lets first add a reference to the types we're using.
At the project level in the Solution Explorer, right click and select Add Reference

Switch to the COM tab, and Choose the "Active DS Type Library"

This will automagically add some things to your project.

These are the magical COM Interop DLLs that are generated for you, and allow you to use the objects inside that library.
Dim up a few objects, to use a bit later.
Dim usr As IADsUser
Dim grp As IADsGroup
Set a reference to your user the same as always, using the WinNT ADSI provider.
usr = GetObject("WINNT://" & TheDC & "/" & UsrName)
Now that the compiler knows what the grp object's type is, it won't puke on you
For Each grp In usr.Groups()
If (grp.Name = "foo" Or grp.Name = "bar") Then
' Do something with it
End If
Next
There are better ways to do this though, Stay tuned for how to totally pimp this out, the ASP.Net 2.0 way.