Question

I am using SharePiont Server 2007 Enterprise with Windows Server 2008 Enterprise. I am developing using VSTS 2008 + C# + .Net 3.5. I am wondering whether SharePoint has any means to set current user to be some specific user? For example, I want to set the user to be administrator automatically when people connects from a specific IP address to grant such people high privilege. Another example is when people connects my sie using special connection string, like http://example.org/default.aspx?specialtestuser=foo, then I will set current user to be foo. Appreciate if any code samples to reference?

Was it helpful?

Solution

In Sharepoint you can use impersonation to execute code in place of a specific user. You can also use this technique to run some section of your code with higher priviledge (better than giving full high priviledge to a user). Here just 2 links but if you search the net for Sharepoint and Impersonation you will find more links.

MSDN on impersonation and other tricks

Impersonation in Sharepoint 2007

I hope this will help


Here another link that propose to set up some HTTP module and that looks a little like you want to do : siteminder and sharepoint 2007

But I never tried this out so I can't help you much more.

OTHER TIPS

SharePoint 2007 fully supports the .NET Provider model, so you can utilize the MembershipProvider model (the SharePoint built-in provider is the LdapMembershipProvider and LdapRoleProvider), which supports the forms based as well as any custom authentication/authorization architecture. You can set the current user from the Membership global object. My caveat would be to use the Membership and Roles object completely throughout your code if you choose this approach.

Nishant's blog is pretty useful for anything MOSS and AD related, and has this post: http://blogs.technet.com/nishants/archive/2009/05/22/how-to-configure-forms-based-authentication-active-directory-ldapmembership.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top