Friday, June 11, 2010

How can i find the currently login user of extended web application through ASP.Net code?

i have created a web application http://spserver:19578 and then i extend a web application http://spserver:19579 from it.

Now i am currently login as ali to http://spserver:19579. i write the following code

SPSite sitecollection = new SPSite("http://spserver:19579");
SPWeb web = sitecollection.AllWebs["/"];
SPUser user = web.CurrentUser;

lblUser.Text = user.Name;

but it returns System Account. and when i used LoginName instead of Name then it returns SharePoint\system.

 

Note: I am using form based authentication in http://spserver:19579 and windows authentication in http://spserver:19578.

 

Reply 1

hey try using SPContext .Current .Web .CurrentUser

No comments:

Post a Comment