Something about something…

something about me
Bet’cha thought I’d skip a month, ‘eh? Well you’d have bet wrong, and you’d have owed money to someone. But you probably didn’t bet, which is probably good. So good, in fact, you might feel generous enough to give, oh, half of what you would have bet to me instead? Except you can’t, because I haven’t put any way of accepting stranger’s money on here. So, yeah… Better luck next time.

Anyway, this post’s less free-game and more personal-blog (except my life is games and tech so, obviously, there’ll be some of that). Sorry. That’s just a little heads-up to the freebie-watchers so they don’t waste their time. You’re welcome.


So this month included my birthday, which makes me /lol-nope/ years old. That was nice, except for the whole ‘older’ part and the ‘WTF life how do I’ thing that seems to go along with it. There were some gifts (chief among them books, lovely sentences by a one Terry Pratchett, and games, Shadowrun and KOTOR), some well-wishes – the regular bunch of niceties. February seems to play host to an uncannily high amount of birthdays, too. Multiple relatives, more friends, assorted acquaintances and strangers… Clearly, things go down in May. Or do they get up? It’s hard to tell. (Not even sorry, nuh uh.)

Oh, right, the point of that last paragraph: happy birthday me!

something about scripting
Ahem. Moving on. Work presented an interesting puzzle recently – scripting! Well, light scripting, admittedly, but I don’t do an awful lot of ‘development’ style work so it stands out as a fun challenge (that, honestly, I’d like more of). Most of my work involves various levels of support to assorted end-users and the care of end-user systems (which is to say I restart things when they’re not working and reset them when they’re forgotten). This case was one of needing to go through a (long) list of user’s names and finding their Active Directory logon names and email addresses (where they existed). I was thrown an Excel spreadsheet containing the names I needed to find, and what I found would need to be added to the spreadsheet. Thus I was set loose to do the thing.

I started off whacking at it all manual-like, but after an hour went by with very little progress to show for it, I thought I might be better off taking the time to figure out how to automate the process and come out of it a) better skilled and b) not brain-dead-bored. Those might be two pellets of the same shotgun shell (or something), but I digress…
Step one was to Google something along the lines of ‘search active directory for list of users from excel‘ and find some likely-looking result. Turns out result number three (at the time, and not counting the first ad result), a Microsoft TechNet Hey, Scripting Guy! Blog was likely.


Apart from giving me a hunger for Turducken, Scripting Guy’s script turned out mighty useful. It took a little head scratching, but eventually I figured out that it’s a VB Script and that to run it, it should be saved as a .vbs file and run via CMD with cscript ala ‘>cscript scripThing.vbs’ (I suppose wscript will also work – I didn’t try it). I don’t remember what lead to that realisation, but it involved more Googling and recollection from the depths of memory of another AD script. After that, the syntax threw me some (mostly where it came to defining my LDAP query and where\how to stick my first- and last-name variables into it), but luckily the light JavaScript that I’ve been going through over at paid some dividends and I was able to figure things out, like where variables were being declared and how the Do Until loop worked (that and Notepad++, instead of foolishly banging on with plain, old Notepad). Now I type it out, it seems awfully simple but these are the troubles of us newbie scripters. Active Directory Users and Computers and the Saved Query/Custom Query thingy helped me make sure I knew what AD values I needed to use (‘givenName’ for the first-name and ‘sc’ for the last).

As helpful as Scripting Guy was, he was really only helping me verify an AD account’s existence, and I needed more than that…
After figuring out how to define my LDAP query and tweaking my search variables to fetch their data my particular Excel spreadsheet, next came actually reading the data from AD so that I could fetch the SAMAccountName’s and email’s I was looking for and drop them into said spreadsheet. Here where Google brought forth a TechRepublic forum post and I went on learning. objRecordset.Fields(“Name”).Value was what I needed: I used it twice, changing “Name” to “email” and “samAccountName” and setting them equal to the cells of the Excel spreadsheet where I needed the email addresses and logon names to go (and where the data I wanted was not found or there were multiple results, a ” would be printed instead).

So I knew how to run my script, how to search my AD, I had the search terms, I had variables and I knew how to write them to my spreadsheet. Next is to just get on with it, right?

Well, no. A final hurdle appeared: I needed to manually specify what DC to use to run my search on. Here Scripting Guy came to my aid again, with a post that struck right to very heart of this latest hump: How to access AD on a specific DC. I fixed the beady eye of my LDAP query on the DC I wanted, and off I went!


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\watNow\suchSpreadsheet.xlsx")
objExcel.Visible = True

i = 2

Do Until objExcel.Cells(i, 1).Value = ""
strFirstName = objExcel.Cells(i,1)
strLastName = objExcel.Cells(i,2)
objCommand.CommandText = _
"SELECT mail,samAccountName FROM 'LDAP://IP.AD.DR.ESS/dc=foo,dc=com' WHERE objectCategory='user' AND givenName='" & strFirstName & "' AND sn='" & strLastName & "'"
Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount = 1 Then
strEmailAdd = objRecordSet.Fields("mail").value
strUsername = objRecordSet.Fields("samAccountName").value
objExcel.Cells(i,5) = strUsername
objExcel.Cells(i,6) = strEmailAdd
objExcel.Cells(i,5) = ""
objExcel.Cells(i,6) = ""
End If

i = i + 1


It worked brilliantly. It was a marvel to watch it open the Excel sheet and automagically populate the cells with the data I wanted. Granted, there were flaws: if the first- and last-names between AD and the spreadsheet weren’t exact matches, or if multiple objects were found with a particular search, I got my ‘‘ output. However, a good three-quarters\four-fifths of the names were found which carved a hefty chunk out of the amount of manual lookup I needed to do. I’m confident that the time I took figuring out how to script this operation was well under how long a manual lookup would have taken, and I had a more interesting work-day to boot. Not only that, I found a helluva resource in Scripting Guy and the TechNet Script Center overall.

something about coding
I also feel like I should point out the benefit of having played with some coding courses on (and others, but is most recent). Not too long ago, picking up the VBS syntax and deciphering the scripts I was looking at would simply not have been a thing that I could do in under a day. The almost ‘natural’ grasp I got of what I was looking at was an illuminatingly empowering feeling.

Since this, I’ve started knocking around with some Android development and continued my learning tracks on Ideas float about in my head all the time, maybe one of them ends up making a good mobile app. First prize, however and of course, is going on to videogame development…

something about vidjagams
And speaking of videogames… Well, Shadowrun: Returns has been my thing for the last two weeks or so. I suppose I’d call it a turn-based action RPG. The turn-based stuff being much like XCOM: Enemy Unknown (to name a recent example), although Shadowrun’s not in 3D (so no rotating the isometric camera) but instead sports a slick 2D/pseudo-3D style that’s rather charming. Unlike XCOM, Shadowrun’s action and gameplay loop is not as smooth. It does have more RPG elements though: rather than the squad-evolution and light individual-unit-progression, you level your own single character for the most part, in a more RPG-typical but well-varied character-traits and skill-trees system. Where XCOM’s narrative was a largely negligible procedural thing, Shadowrun’s story and narrative proves to be one its most engaging aspects. The steampunk ‘n magic world and noir detective ‘n retribution story do a good job of capturing your interest and will see you pushing that bed-time out further and further ’cause you just wanna see whodunnit.

There was also a bit of Battlefield: Hardline’s beta. It was certainly fun, but I’m not interested in buying another Battlefield that just ends up with a player-base split all to hell by expansions and premium, then, in South Africa at least, only sees any activity on vanilla game servers within two weeks of any expansion dropping. Also, bloody hell do Premium and/or the expansions of these things work out to be pricey…

Lastly, there’s been Star Citizen. I backed Star Citizen right at its start and I’ve followed it very closely since. The promise of a nuts and bolts space sim the way SC is shaping up has me giddy; fond memories of Freelancer and X – beyond the frontier (yes the original X, and yes those are pretty much the only space flight games I really did much with) keep me itching for more, and the CIG team and Chris Roberts look well on track to deliver the goods. I have wanted to write about SC for some time and even drafted an ‘impressions’ post shortly after the initial launch of Arena Commander (or the DFM), but never did finish it and now it’s old. A new one might happen one day, but for now I have been having a good time with AC. I play with a HOKAS (Hands On Keyboard And Stick) setup, and while my over-bearingly FPS-focussed history is not doing me any favours with the stick, the experience is immersive and piloting my sexy 300i is something I just want to keep doing.


And that’s that for this one. Just shy of 1700 words, not bad. Hope it was worth reading. ;)

Oh, if you’re wondering what the ‘something about x’ things are for: they’re leftovers of my post-planning. I knew I wanted to type words about those things, but there was the matter of figuring out what the words would be…