如何找到登录的用户在Sharepoint? [英] How to find the logged in user in Sharepoint?

查看:139
本文介绍了如何找到登录的用户在Sharepoint?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我公司开发的Web部件有部署在SharePoint服务器上。我需要的用户,谁在Web部件内SharePoint服务器登录的用户名。

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;



你的,
Jigar 3;

Yours, Jigar <3

这篇关于如何找到登录的用户在Sharepoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆