They say you learn something new every day.

Posts tagged ‘aspx’

Asps in Nets (31/01/2012)

I’m struggling a little bit with .Net. It’s a little bit different from languages I’ve used before, and I’m worried that I’m falling back on what I know a bit – doing things in less efficient ways because that’s how I’ve always done them.

This is a bit of a problem really. What’s always inspired me to learn something new is the drive to get something to work. If I can get it to work, albeit in the “wrong” way, then I tend to stop.

Now, on the one hand, this may result in code that’s a little tatty, but on the other, the user doesn’t care. What they want is the functionality, and if it looks nice, works and is easy to use, they’re happy.

If it’s written in nice OOP code, or cobbled together from bits and bobs then they’re happy.

Now, I’m not advocating crappy code in any way. Oh God no, I’ve had enough problems with my own crappy code without writing more. But what I’ve realised is that more important than the neatness of the code is the richness of the application.

It’s much more important to get the functionality in there, make it work and tweak from there.

I realised this when putting together this function to return the group membership for a particular computer. It’s a little cobbled together, but it works. And now that I’ve got the functionality I can start tweaking it to make it work better and faster, and start identifying faults and fixing them.

I think people need to remember. We don’t code to write code. We code to solve a problem. 

FUNCTION GetMembers(Asset AS String) As String

DIM members

DIM objADAM As DirectoryEntry = New DirectoryEntry() 


DIM objSearchADAM As DirectorySearcher = New DirectorySearcher(objADAM)

objSearchADAM.Filter = “(&(cn=” & Asset & “))”

objSearchADAM.SearchScope = SearchScope.Subtree

DIM objSearchResults As SearchResultCollection = objSearchADAM.FindAll()

If objSearchResults.Count 0 Then

Dim objResult As SearchResult

For Each objResult In objSearchResults

DIM memberof AS Object =“memberof”).value

IF NOT IsNothing(memberof) THEN

DIM collectiontotal= objResult.GetDirectoryEntry().Properties(“memberOf”).Count -1

Dim member,adgroup, i

For i = 0 To collectiontotal

member = objResult.GetDirectoryEntry().Properties(“memberOf”)(i).ToString(

members = members & member


members = “There are no groups on this computer.”


Next objResult


members = “Computer could not be found.”

End If

GetMembers = members


It’s .Net the End of the World (10/01/2012)

long time ago (at least it feels a long time ago), I mentioned that I’d be learning some more ASP.Net soon. It seems that day is today.

I’m building a platform at work for communicating software information, getting information back about non-usage, duplications and prohibited software.

The idea really is to make it as flexible as possible, and as low effort on the user as possible. This means a few things:

  1. Single sign on (that is, the application gets your user id, and then looks up data relevant to you). Really I don’t know why every business Intranet site isn’t single sign on.
  2. Sparse interface. It’s a very simple idea, so I want to keep the interface as straight forward as possible. The buttons will be big and clear and there won’t be many of them (usually just yes and no).
  3. Single summary push emails. If there are 10 updates, that shouldn’t mean 10 separate emails, it should mean one eMail with them all in. Maybe sent weekly or monthly. I like the Facebook way of handling this (well, I don’t – I don’t care about my pending notifications, but I like the idea).

The first thing I needed to learn, then, was how to get the logged in user ID so I could do something with it.

It turns out is actually quite different from PHP and Classic ASP (and basically every other coding language I’ve used). It’s an abstraction layer, and all sorts of things happen between you writing the code and it being posted. However, the thing I picked up today was how to get the username.

Sub Page_Load()
Dim Username = User.Identity.Name
Message.Text = MID(User.Identity.Name,INSTR(User.Identity.Name,””)+1)
End Sub

This bit is quite standard, and what I use to trim off the domain to return just the userid:


But the rest is actually quite weird. However, now that I’ve started using this, I think I might like it a lot – it seems very easy to build pages. Easier than php or classic ASP, which is strange as I thought you were meant to be paid for coding in .Net. Strange, eh?

Tag Cloud