如何在 Sharepoint 中找到已登录的用户? [英] How to find the logged in user in Sharepoint?
本文介绍了如何在 Sharepoint 中找到已登录的用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发了一个必须部署在 Sharepoint 服务器上的Web 部件".我需要用户的用户名,该用户已登录 Web 部件内的共享点服务器.
I have developed a "web part" that has to be deployed on a Sharepoint server. I need the username of the user, who has logged in the sharepoint server within the web part.
我如何获得该用户名?
推荐答案
大家好,我的问题得到了答案希望这对你们有用...首先在 Web 部件中添加对 MicrosoftSharepoint.dll 文件的引用.然后写使用 Microsoft.SharePoint;
Hey all, i got the answer for my question Hope this will work for you all... First add a reference to the MicrosoftSharepoint.dll file in your web part. then write using Microsoft.SharePoint;
string username;
string sspURL = "URL where Sharepoint is deployed";
SPSite site = new SPSite(sspURL);
SPWeb web = site.OpenWeb();
SPUser user = web.CurrentUser;
username = user.LoginName;
site.AllowUnsafeUpdates = true;
你的,吉加尔<3
这篇关于如何在 Sharepoint 中找到已登录的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文