Following was my response to that:
check that if the current user is authenticated or not. u may try this if block:
and if u come to know that the user is not authenticated (which i am sure u will find) then this means that like most of us u have enabled anonymous access. try disabling it and then run ur code by selecting windows authentication mode in your directory security settings in IIS.