December 13, 2005

VB and loathing: in search of an SID

Seems that once every six months or so I have to brush off my VB6 knowlegde to get some work done. Have I mentioned I hate VB6. Did I mention I REALLY hate VB6 when I have to make calls to the Win32 API.

So the reason for my displeasure at this point was I need to get any domain users SID (Security ID). BTW: you can't seem to get this in .NET either, without going back to into the Win32 API -- no nice OO wrapper goodness for this one. How fun.

The particular API I am using actually requires one to be able to add a user. It is part of their security process. Lovely. So after a day of searching through the bowels of Google, I found my answer -- not all in one place. No, that would be too easy.

So, if any of you are needing a user's SID and are playing with the LookupAccountName and ConvertSidToStringSid APIs from VB6, here is some help.



Private Declare Function ConvertSidToStringSid Lib "ADVAPI32.dll" Alias "ConvertSidToStringSidA" (ByVal Sid As String, ByRef lpStringSid As Long) As Long
Private Declare Function IsValidSid Lib "ADVAPI32.dll" (ByRef pSid As Any) As Long
Private Declare Function LookupAccountName Lib "ADVAPI32.dll" Alias "LookupAccountNameA" (ByVal lpSystemName As String, ByVal lpAccountName As String, ByVal Sid As String, ByRef cbSid As Long, ByVal ReferencedDomainName As String, ByRef cbReferencedDomainName As Long, ByRef peUse As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Function GlobalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long
Private Declare Function LocalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal wBytes As Long) As Long
Private Declare Function LocalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long

Private Sub Command1_Click()
MsgBox GetSid("DOMAIN\USER")
End Sub


Private Function GetSid(accountName As String) As String

Dim userName As String
Dim UserNameSize As Long
Dim Sid As String
Dim SidSize As Long
Dim Domain As String
Dim DomainSize As Long
Dim snu As Long
Dim sReturn As String

userName = String$(255, 0&)
Sid = String$(255, 0&)
Domain = String$(255, 0&)
sReturn = String$(255, 0&)

UserNameSize = 255
SidSize = 255
DomainSize = 255

Call LookupAccountName(vbNullString, accountName, Sid, SidSize, Domain, DomainSize, snu)
If IsValidSid(ByVal Sid) = 0& Then Exit Function

Call ConvertSidToStringSid(Sid, snu)
Call CopyMemory(ByVal sReturn, ByVal snu, 255)

sReturn = Left$(sReturn, InStr(vbNull, sReturn, vbNullChar, vbBinaryCompare) - vbNull)
Call GlobalFree(snu)

GetSid = sReturn
End Function

December 08, 2005

Delphi News: Thorpe gone to Google

OK, this can't be good for the Delphi community.

According to CNET (see article here), Danny Thorpe has left Borland for Google.

I dont see this as a death nel for Delphi, but it is another set of shoes that now have to be filled.

November 18, 2005

My Visual Studio.Net Launch event

So, my Visual Studio.Net 2005 launch event was last night. it was on "Creating cutting edge web applications with ASP.NET 2.0"

When I say "My launch event", I mean I was giving the presentation to a tent full of developers, next to a hospital, and within earshot of a freeway.

And when I say "tent", I mean a massive industrial tent with 1 foot thick walls, air-conditioned with aluminum duct work, anchored to the ground with steel beams bolted in concrete, sound system, overhead projector, and fluorescent lighting. Everything we needed but a bathroom. But it was still a tent.

Anyway, the presentation went ok. Not great, but not terible either, just a nice solid "it could have been better" ranking.

Being a canned presentation I recieved from Microsoft less than month before I was supposed to give it...I'm almost happy with how I did. And of course, I recieved a few questions that I didn't know the answer to. Luckely, there was usually someone in the audience who did know the answer.

In the end, it was a lot of work to prepare for this -- a lot of time my wife wants back now. It seems even worse when you consider that I was not paid it. But...I like doing this sort of thing. I actually think it is kind of fun.

Just out: NUnit 2.2.3

A new version of NUnit is out that is compatible with Visual Studio.Net 2005 and the 2.0 framework.

Read about it here:
http://nunit.com/testweb/index.php?p=releaseNotes&r=2.2.3

Download it from here:
http://nunit.com/testweb/index.php?p=download

November 17, 2005

Dilbert gets it

For some reason I think this Dilbert is briliant, hilarious, and so true it makes me want to cry.

http://www.dilbert.com/comics/dilbert/archive/dilbert-20051116.html

Microsoft going 64 bit only

This is all over Slashdot and dig this morning.

Aparently Microsoft is only going to release server software in 64 bit version from now on.
Starting with Exchange 12.

Anyway, here is a link to the story: http://news.com.com/Microsoft+makes+its+way+to+64-bit+chips/2100-1012_3-5953714.html?tag=cd.top

November 11, 2005

Bad days

Ever have a week bad enough to make you wish for alcohole?

Yes. Me too.



Note: this is still better than milking cows for a living -- but the gap has narrowed a bit this week.

November 07, 2005

Good lord it is hereditary

This is not good. I just found out a teenage niece of mine has a blog, and her grammar is worse than mine.

Here is a typical sentence:
"we almost one are last volleyball game"

At first I though this was some sort of teenage code that I've here-to missed because I'm 30. I re-read it. No, that isn't it. Then I thought, maybe this is just some sort of new blooger shorthand used by the younger generation. After all, blogging is pretty new, and I'm sure my niece is heavily addicted to IM. No, not enough acronyms in that thing that was almost a sentence.

I'm sure I'm having a slow brain day, because this took me almost 2 minutes to figure out the cause. She has inherited my bad English skills. This is really odd because, generally, only the males in my family are affected. Really, you think my grammar is bad, you should see some of my cousin's writing potential. It aint there. Never had it, never will. And trust me, there are many a burnt out English teacher in my wake as I was trying to get though high school and college. Not to mention badly used pieces of paper and now ill tempered ink pens.

But that said, after reading some of the comments left in her blog (note: I'm not actually mean enough to leave a link to her blog here), I see that most of her friends are not doing much better in their comments. Between lack of capitalization, spontaneous punctuation, misplaced acronyms (example: “LOLOLOLOLOLO”), spelling worse than I can muster (I do know how to use spell check and a dictionary), and excessive adjectives; I see my niece keeps herself in good company.

Actually, on the punctuation, I’m not sure if that wasn’t intentional. Considering how many times I’ve seen her speak a run-on sentence or three -- seeing her write one should not be that surprising. I'm sure many people have seen a teenage girl literally talk themselves blue in the face, sometimes having to breath in the middle of their fourth run-on sentance, or pass out entirely. I mean, really, do they train for that?

Note to self: Never try to win a breath holding contest against a teenage girl.
Note to self 2: That could be a really good way of shutting up a teenage girl. Cheating should be considered legal and praise worthy in this case. Bonus credits if said teenage girl passes out.

Anyway, I wont waist too much time looking for her in the honor role this year.

Get Visual Studio.NET Express

OK, today Visual Studio.NET 2005 was officially released.

Along with that, the express products were also set free.
Free as in: free to download.

http://msdn.microsoft.com/vstudio/express/

This includes versions for C#, VB.NET, C++, Web Development, and SQL Server.

They are not in the same class as the professional version, but the price is hard to pass up.

Digg.com: the new Slashdot?

A friend of mine recently turned me to this site.
www.Digg.com
Think: "Do you digg it?"

It was created by some guys who were fed up with Slashdot.
What these guys did not like was that the editors of Slashdot have ultimate control over what gets posted.
On Digg, the users over what gets posted. Once a new article is posted, the users can then rate the post (you just say you digg the article, there is no "I don't digg it" button to confuse things). From there you can see the top rates stories of the day/week/month/year. Also, each post is categorized, so you can pick the posts by that as well.

It very much reminds me of the Google simplicity in design (think gmail). Not that Slashdot is overly cluttered, but Digg is very stream lined and easy to navigate.

So far, I like it.