简体   繁体   English

如何在SharePoint中设置当前用户名?

[英]how to set current user name in SharePoint?

I am using SharePiont Server 2007 Enterprise with Windows Server 2008 Enterprise. 我正在将SharePiont Server 2007企业版与Windows Server 2008企业版一起使用。 I am developing using VSTS 2008 + C# + .Net 3.5. 我正在使用VSTS 2008 + C#+ .Net 3.5开发。 I am wondering whether SharePoint has any means to set current user to be some specific user? 我想知道SharePoint是否有任何方法可以将当前用户设置为特定用户? 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. 例如,当人们从特定IP地址进行连接以授予这些人较高的特权时,我想将用户设置为自动成为管理员。 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. 另一个示例是当人们使用特殊的连接字符串(例如http://example.org/default.aspx?specialtestuser=foo)连接我的sie时,我将当前用户设置为foo。 Appreciate if any code samples to reference? 欣赏是否有任何代码示例可供参考?

In Sharepoint you can use impersonation to execute code in place of a specific user. 在Sharepoint中,您可以使用模拟来代替特定用户执行代码。 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. 这里只有2个链接,但是如果您在网上搜索Sharepoint和模拟,您会发现更多链接。

MSDN on impersonation and other tricks 关于假冒和其他技巧的MSDN

Impersonation in Sharepoint 2007 在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 这是另一个建议设置一些HTTP模块的链接,看起来有点像您想做的: siteminder和sharepoint 2007

But I never tried this out so I can't help you much more. 但是我从来没有尝试过,所以我无法为您提供更多帮助。

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. SharePoint 2007完全支持.NET Provider模型,因此您可以利用MembershipProvider模型(SharePoint内置提供程序为LdapMembershipProvider和LdapRoleProvider),该模型支持基于表单以及任何自定义身份验证/授权体系结构。 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. 我的警告是,如果您选择这种方法,则将在整个代码中完全使用Membership and Roles对象。

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 Nishant的博客对于与MOSS和AD相关的任何事情都非常有用,并且具有以下帖子: http : //blogs.technet.com/nishants/archive/2009/05/22/how-to-configure-forms-based-authentication-active -directory-ldapmembership.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM