tags:

views:

202

answers:

2

We have a sharepoint feature which gets activated on 'MySite' creation. We need to get the logged in user's active directory user name in that feature...So we have used HttpContext.Current.User.Identity.User.Name but it throws following exception "System.ArgumentException: Account name cannot be an empty string."

Any idea why is it blank ? Or is there some other way where we can get logged in user's AD user name ??

Appreciate any help.

+1  A: 

I am not sure about "Mysite". However in general you need to have "Integrated windows Authentication" selected. You may reach to this option via

IIS->website->properties->Directory Security->Authentication and Access control -> Edit

Also if have your web.config you should have authentication mode as "windows".

If it is not helpful post more info about the "feature", how it is coded? where is is published?

Mani
+2  A: 

Try SPContext.Current.Web.CurrentUser.LoginName

F.Aquino
This won't work in my case for example if the logged in user belongs to Administrative group then instead of showing actual AD user name it always shows DOMINANAME\System Acount
Nikhil Vaghela
That should only be the case if the logged in user is the System Account. What administrative group are you referring to?
Kyle Trauberman