Navigation

Search

Categories

On this page

Now selling Grelling–Nelson premium coffee, powered with premium coffee beans.
Forcing an MS SQL Database to close connections
Group Membership in .net

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Wednesday, September 19, 2007
Wednesday, September 19, 2007 12:49:39 PM (Mountain Daylight Time, UTC-06:00) ( )

You might know that I'm a very adamant Microsoft.Net guy. As such, it's always highly amusing to me when I see 'the other side of the universe' talk about how their product is so very very good, by self referencing itself during the install process.

I'm sure glad they cleared that up. I thought I was going to have Java that was powered by Kittens. I'm sure glad that Java does in fact power itself.

Is that the best these people's marketing professionals can come up with? An autological phrase? Puh-lease.

Maybe they really do power it with kittens... which in turn are hopped up on Java... that would be so much cooler.

Comments [0] | | # 
# Wednesday, July 25, 2007
Wednesday, July 25, 2007 10:08:28 AM (Mountain Daylight Time, UTC-06:00) ( )

use master
ALTER DATABASE <database>
SET SINGLE_USER WITH ROLLBACK IMMEDIATE

-- do work here

use master
ALTER DATABASE <database> SET MULTI_USER WITH ROLLBACK IMMEDIATE;

Comments [0] | | # 
# Thursday, May 24, 2007
Thursday, May 24, 2007 11:18:41 AM (Mountain Daylight Time, UTC-06:00) ( All things Microsoft | Code )

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.

Comments [0] | | #