Technet blog

Finally I have published my first TechNet blog post, you can find it at the following link:


Some more links

PowerShell: Learn It Now Before It's an Emergency

TechNet Webcast: ICE: The Secret of Edge Media Connectivity in Communications Server 2007 R2

Active Directory WebCasts

A lot of people have asked me for resources guidance for learning Active Directory, and each time I dig up these AD inside out links and send it to them. I am posting these links here for future reference.

TechNet Webcast: Active Directory Inside Out

(Part 1 of 11) — Active Directory Logical Concepts — Level 200

(Part 2 of 11) — Active Directory Physical Concepts — Level 200

(Part 3 of 11) — Active Directory Replication and the Operations Masters Role — Level 200

(Part 4 of 11) — Installing and Managing DNS — Level 200

(Part 5 of 11) — DNS Features and Configuration — Level 200

(Part 6 of 11) — Interoperability and Migration from Novell Directory Services — Level 200

(Part 7 of 11) — Migrating File Resources from NetWare to Active Directory 2003 — Level 200

(Part 8 of 11) — Deployment and Interoperability with NT 4.0 and Windows 2000 — Level 200

(Part 9 of 11) — Administration Features — Level 200

(Part 10 of 11) — Replication Features and Forest to Forest Trusts — Level 200

(Part 11 of 11) — Group Policy Management Console and Software Restriction — Level 200

Bonus Links:
I'm a General Sysadmin, Not an Active Directory Expert! A Crash Course in Active Directory (Part 1 of 2) (Level 200)
I'm a General Sysadmin, Not an Active Directory Expert! A Crash Course in Active Directory (Part 2 of 2) (Level 200)

The night belongs to the poets and the madmen

Midsummer night's dream

More strange than true: I never may believe
These antique fables, nor these fairy toys.
Lovers and madmen have such seething brains,
Such shaping fantasies, that apprehend
More than cool reason ever comprehends.
The lunatic, the lover and the poet
Are of imagination all compact:
One sees more devils than vast hell can hold,
That is, the madman: the lover, all as frantic,
Sees Helen's beauty in a brow of Egypt:
The poet's eye, in fine frenzy rolling,
Doth glance from heaven to earth, from earth to heaven;
And as imagination bodies forth
The forms of things unknown, the poet's pen
Turns them to shapes and gives to airy nothing
A local habitation and a name.
Such tricks hath strong imagination,
That if it would but apprehend some joy,
It comprehends some bringer of that joy;
Or in the night, imagining some fear,
How easy is a bush supposed a bear!


Just what the name says.

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

alias ls="ls -qCF --color"
set autoexpand
set autolist
alias cls=clear
PS1='\[\033]0;\w\007\033[32m\]\u@\h \[\033]0;\w\007\033[35m\]\@ \[\033[33m\w\033[0m\] \$ '
export LANG=
export PATH=${PATH}:/sbin:/usr/sbin
alias fixterm='echo -e "\017\e[?7h\c" ; stty echo ; resize'
alias fixterm2='stty rows 40; /bin/echo -en "\033[1;40r";clear'
sshremove () { sed -i /"^$* "/d ~/.ssh/known_hosts ; }

The SIP Labyrinth

RFC2327 SDP: Session Description Protocol
RFC2806 URLs for Telephone Calls
RFC2833 RTP Payload for DTMF Digits, Telephony Tones and Telephony Signals
RFC2474 Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers
RFC2976 The SIP INFO Method
RFC3261 SIP: Session Initiation Protocol
RFC3262 Reliability of Provisional Responses in the Session Initiation Protocol (SIP)
RFC3263 Session Initiation Protocol (SIP): Locating SIP Servers
RFC3264 An Offer/Answer Model with the Session Description Protocol (SDP)
RFC3265 Session Initiation Protocol (SIP)-Specific Event Notification
RFC3266 Support for IPv6 in Session Description Protocol (SDP)
RFC3311 The Session Initiation Protocol (SIP) UPDATE Method
RFC3323 A Privacy Mechanism for the Session Initiation Protocol (SIP)
RFC3325 Private Extensions to the Session Initiation Protocol (SIP) for Asserted Identity within Trusted Networks
RFC3326 The Reason Header Field for the Session Initiation Protocol (SIP)
RFC3420 Internet Media Type message/sipfrag
RFC3515 The Session Initiation Protocol (SIP) Refer Method
RFC3550 RTP: A Transport Protocol for Real-Time Applications
RFC4028 Session Timers in the Session Initiation Protocol (SIP)
RFC4032 Update to the Session Initiation Protocol (SIP) Preconditions Framework
RFC4485 Guidelines for Authors of Extensions to the Session Initiation Protocol (SIP)
RFC4566 SDP: Session Description Protocol
RFC5806 Diversion Indication in SIP

RFC3853 S/MIME Advanced Encryption Standard (AES) Requirement for the Session Initiation Protocol (SIP)
RFC4320 Actions Addressing Identified Issues with the Session Initiation Protocol's (SIP) Non-INVITE Transaction
RFC4916 Connected Identity in the Session Initiation Protocol (SIP)
RFC5393 Addressing an Amplification Vulnerability in Session Initiation Protocol (SIP) Forking Proxies
RFC5621 Message Body Handling in the Session Initiation Protocol (SIP)
RFC5626 Managing Client-Initiated Connections in the Session Initiation Protocol (SIP)
RFC3327 Session Initiation Protocol (SIP) Extension Header Field for Registering Non-Adjacent Contacts
RFC5630 The Use of the SIPS URI Scheme in the Session Initiation Protocol (SIP)
RFC3608 Session Initiation Protocol (SIP) Extension Header Field for Service Route Discovery During Registration

Automatically enable Out Of Office (OoO) message when you close Outlook

I work in an environment where my work hours are not fixed and I interact with people across the globe, so it becomes important for me to let my customers/team members know when I am not in office.

The easiest way to do this is by using Out Of Office(OoO) messages when I am not available. The problem is that a lot of times in a hurry to leave office I forget to set up an OoO message.

Along with some friends I came up with the idea of using a VBScript Macro in Outlook to dynamically generate and set an OoO every time I close my outlook. The resulting script is as follows:

Function Workday(BegDate As Date, NumDays As Integer)
Dim EndDate As Date
EndDate = BegDate

If NumDays < 0 Then StepCount = -1 Else StepCount = 1 End If While NumDays <> 0
NumDays = NumDays - StepCount
EndDate = EndDate + StepCount
EndDay = DayOfWeek(EndDate)
If EndDay = "Sat" Then
If StepCount = -1 Then
EndDate = EndDate - 1
EndDate = EndDate + 2
End If
End If
If EndDay = "Sun" Then
If StepCount = -1 Then
EndDate = EndDate - 2
EndDate = EndDate + 1
End If
End If

Workday = EndDate
End Function

Function DayOfWeek(ddate As Date)
' seed some monday
Dim seed As Date
seed = "1/3/2005"

If DateDiff("d", seed, ddate) > 0 Then
cycle = 0
cycle = 1
End If

diff = DateDiff("d", seed, ddate, vbMonday)

If cycle = 0 Then
diff = Abs(diff + 2) Mod 7
diff = Abs(diff - 4) Mod 7
End If

If cycle = 0 Then
If diff = 0 Then
DayOfWeek = "Sat"
End If

If diff = 1 Then
DayOfWeek = "Sun"
End If

If diff = 2 Then
DayOfWeek = "Mon"
End If

If diff = 3 Then
DayOfWeek = "Tue"
End If

If diff = 4 Then
DayOfWeek = "Wed"
End If

If diff = 5 Then
DayOfWeek = "Thu"
End If

If diff = 6 Then
DayOfWeek = "Fri"
End If
If diff = 6 Then
DayOfWeek = "Sat"
End If

If diff = 5 Then
DayOfWeek = "Sun"
End If

If diff = 4 Then
DayOfWeek = "Mon"
End If

If diff = 3 Then
DayOfWeek = "Tue"
End If

If diff = 2 Then
DayOfWeek = "Wed"
End If

If diff = 1 Then
DayOfWeek = "Thu"
End If

If diff = 0 Then
DayOfWeek = "Fri"
End If
End If
End Function

Private Sub Application_Quit()

Dim objMAPISession As Object
Set objReminders = Nothing
Set objMAPISession = CreateObject("MAPI.Session")
objMAPISession.Logon , , True, False
If (objMAPISession.OutOfOffice = False) Then
strCannedMessage = "Dear Sender," & vbCrLf & vbCrLf & "Thank you for your e-mail, I am presently out of office and will return on " & FormatDateTime(Workday(Now(), 1), vbLongDate) & ". If this e-mail requires urgent attention please call +91 XX XXXX XXXX." & vbCrLf & vbCrLf & "You can also contact my manager Sam Snead ([email protected]) at +91 XX XXXX XXXX." & vbCrLf & vbCrLf & "Regards," & vbCrLf & "Akshat"
objMAPISession.OutOfOfficeText = strCannedMessage
objMAPISession.OutOfOffice = True
End If
Set objMAPISession = Nothing

End Sub

If you trust me and want to set it up right now, open your Outlook and head to "Tools > Macro > Visual Basic Editor" (you can press Alt + F11 to launch the editor as well). This should launch a new editor window, in the left pane of this window expand "Project > Microsoft Office Outlook > ThisOutlookSession" and paste the script above in the right pane. Hit the save icon and you are all set.

There are a lot of tweaks that can be made to the script, for example, prompting the user, checking for holidays etc but for now, I am happy with this script.

PS: Someday, I will type in an explanation of the code. Not today...

Use an Outlook Macro to Stop Forgetting the Subject Line

SSH Public Key Authentication

Tired of having to type passwords each time you login to a remote machine via ssh?
Here is a quick and dirty cheat sheet to enable Public Key Authentication for SSH:

1. Generate a new key for your own machine

"$ sudo ssh-keygen -t rsa"
2. Transfer the key to the remote machine
"$ sudo scp ~/.ssh/ remote-machine:.ssh/authorized_keys2"

And that's it you are done. If the remote machine does not have the .ssh directory, just run the step 1 on remote machine as well.

If you are using PuTTY to connect to the remote machine, you can still use Public Key Authentication. To generate a public/private key pair for your windows machine,

1. download and execute PuTTYgen.
2. Click on Generate button.
3. Move the mouse in the empty area to generate a random seed value for the keys.
4. Save the Public Key and Private Key to a folder (I use the same folder as PuTTY)
5. Launch PuTTY and navigate to "Connection > SSH > Auth" and then click on "Browse"
6. Select the Private Key created in step 4 (.ppk file)
7. Select "Session" in the left pane again.
8. Select "Default Settings" and then click on "Save"

This configures your PuTTY client to use the Private key for authentication. Now we need to add the public key to the remote machine(s):
9. Login to the remote machine using SSH
10. Edit the fie ~/.ssh/authorized_keys2"
11. Append the contents of Public Key created in Step 4 to the file and save.

That's it, you should now be able to SSH to the remote system without requiring a password. For a more detailed explanation look here.

Convert accountExpires, lastLogonTime etc to a readable date format

Today I got a csvde dump for a bunch of accounts, one of the fields that I was interested in was the accountExpires field and I needed a quick and dirty way to convert the integer8 type data (or a 64-bit signed integer, system.INT64??)to something I could make sense of.

The accountExpires attribute, along with a lot of other attributes such as lastLogonTime, pwdLastSet, badPasswordTime etc store time as number of 100-nanoseconds intervals since 12:00AM since January 1, 1601. Look at R Muller's site (link below) for more information.

I turned to my scripting instincts and looked for ways to code something to convert this number into something which makes more sense to me. The problem is that most of the scripts floating around assume that you have access to the (Active) directory to fetch the data in proper format and then convert them.

One such script that I came across (sorry, forgot the link) had this gem of a command embedded to convert the time using Windows time service. You can run the following command to convert an integer8 number to Date/Time format easily:

w32tm /ntte <integer8-number>

For eg.
w32tm /ntte 9223372036854775807

Hope this helps you in a pinch.


Exchange 2007 OWA: HTTP 400 Bad request

I installed an Exchange 2007 system in my lab for some testing, after the install I noticed that opening http:///owa resulted in Access denied error messages.

After looking at the IIS settings, i found that you have to use secure http to access OWA (yes its been a long time since I touched Exchange), so I changed the URL to https://< ip-address >/owa and that started giving me HTTP 400 Bad request error in explorer. The same URL worked in Firefox. Weird s:

After a bit of fumbling around I did the following to fix the issue:

1. Add an entry for the server name in the hosts file on my system. Since Exchange is in a lab, and I am testing from my own system I need to ensure that my system can lookup the exchange server properly.

2. Add an exception for the FQDN in your Internet proxy settings ( i.e. if you use a proxy server)

3. Use https://< fqdn-of-exchange-server >/owa

Find It