Ugly Code

With my recent project, I had to do some research for the bits that make up the msRTCSIP-OptionFlags field in Active Directory for OCS users. There were certain operations that are not 100% supported by HMC so often times you have to fill in the gaps. The definition of this field is as follows:

This attribute specifies the different options that are enabled for the user or contact object. This attribute is a bit-mask value of type integer. Each option is represented by a bit. This attribute is marked for Global Catalog replication.

source

Unfortunately, in my searching I found not only the technet article, but I also found this

Here a sample of some of the code that you’ll find….

if strOptionFlag = "" then
objUser.Put "msRTCSIP-OptionFlags", "16"

else

‘If user not enabled then do not enable OCS
if strOptionFlag = "0" then
objUser.Put "msRTCSIP-OptionFlags", "0"
‘If user is enabled for Public IM then keep Public IM enabled and enable RCC
elseif strOptionFlag = "1" then
objUser.Put "msRTCSIP-OptionFlags", "257"
‘If user is enabled for RCC then keep RCC enabled and enable Enhanced Presence
elseif strOptionFlag = "16" then
objUser.Put "msRTCSIP-OptionFlags", "272"
‘If user is enabled for RCC and Public IM then keep RCC & PIM enabled and enable Enhanced Presence
elseif strOptionFlag = "17" then
objUser.Put "msRTCSIP-OptionFlags", "273"
‘If user is already enabled for RCC and Enhanced Presence then keep settings
elseif strOptionFlag = "272" then
objUser.Put "msRTCSIP-OptionFlags", "272"
‘If user is already enabled for RCC, PIM and Enhanced Presence then keep settings
elseif strOptionFlag = "273" then
objUser.Put "msRTCSIP-OptionFlags", "273"
end if
end if

All I have to say is wow! You’ve got to be freaking kidding me. Are there programmers out there that don’t understand what a bitfield is supposed to be or how to do bitwise operations? That’s like the first freaking class in a Computer Science degree. This is where you learn about Big 0, Binary numbers, loops, variables. If you are a programmer reading this blog and you don’t know what a bit field is and how to us it. Google it, read up, and rid the world of ugly ass code like what I found above.

Now technically what this person is doing would “work” since it is setting the integer with an appropriate number. But wow is this the WRONG way to do it. I’m afraid to see this persons code for when they need to check and see if the RCC bit is set for the user. Technically, they should be able to do a simple bitwise operation and check it something along the lines of:

if(($msRTCSIP-OptionFlags & 0x0010) != 0)
{
// RCC is set
}

I have a feeling that this person is doing for the following:

if(value == 273)
{
X is set
Y is set
Z is set
}
else if(value == 257)
{
Y is set
Z is set
}

This is a very simplistic psuedo-code example. But wow…I’m still in shock that this type of code is out there…and posted somewhat recently in October of 2008!

I really hope I run into this guy some day so I can beat him with the clue-by-4.

First!

There are very few times that a company gets to claim that they are first to do something. But today, my project is launching and LightEdge Solutions gets to claim that we are the first service provider to provide this integration. Today we are announcing that we are rolling out our Hosted Office Communication Server 2007 service. The real kicker for this is that we have been able to successfully tie together the hosted OCS system with our hosted Broadsoft phone system. So now when you are on a call, it automatically updates your status so everyone in your company will know not to bother you at that time. This is taking the presence integration to that next level.

I’m pretty proud of my team and the work that we have put in. We had a few obstacles in the road that we had to deal with but the guys came through in a huge way. It wasn’t easy, but the good stuff never is.

Links:
Full Press Release

Office Communicator Hotfixes

Not many people are aware of this. But “Microsoft Office Communicator hotfixes are not part of Windows Update, so it is important to find and deploy them through other means.” (source)

I’m completely baffled on how this happened. In the Mac Messenger version, the update is handled by the standard office update. Someone on the Windows side completely dropped the ball. And I’m willing to bet that there are a _lot_ of admins out there that don’t know that this is the case.

Let’s hope that there isn’t an exploit in the OCS client anytime in the near future or there are going to be a lot of late hours patching workstations.