Thursday, 24 April 2008

Determining the Current User Context inside Sharepoint

What's the best way to determine the current user within a custom web part developed for MOSS 2007? I've found four solutions so far, but I'm pretty sure there are more:
1. Use System.Web.HttpContext.Current.User.Identity.Name, like in any ASP.Net web application
2. Use System.Security.Principal.WindowsIdentity.GetCurrent().Name
3. Have the Current User Filter send the current user to your web part, and (of course) make your web part a consumer of that value.
4. SPWeb web = SPControl.GetContextWeb(Context); SPUser currentUser = web.CurrentUser;

StsAdm Path

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

Thursday, 17 April 2008

Getting 404 on Peopleresults.aspx

Q.
Trying to setup a people search. I noticed there was a web-part forthis, I've added it to my main page but when I search for something Igot a 404 not Found on peopleresults.aspx.
Sol.
In sharepoint 2007 it will throw 404 if by default if you have not created a site
with Search Center Template. Create a new sitecollection and in the Template
select Enterprise -> Search Center template (with Tabs or regular).
Once you have the site create you will just select People Search Webpart
Edit -> Modify Shared WebPart and in the Miscellaneous section change theTarget search results page URL to /sites/SearchCenter/results.aspx.Where i have created "searchcenter" i createde it under "sites", try to search after
that guess it will work..

JJ