sharepoint中当前登录用户的名称
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sharepoint中当前登录用户的名称相关的知识,希望对你有一定的参考价值。
Returns the username (domainusername) of the user that is currently logged in sharepoint. Can be used inside features / custom pages
/// <summary> /// Returns the username of the currently logged in user /// </summary> private string CurrentUserName() { string userName = "NA"; SPContext currentContext; try { //Getting the current context currentContext = SPContext.Current; } catch (InvalidOperationException) { currentContext = null; } if (currentContext != null && currentContext.Web.CurrentUser != null) { userName = SPContext.Current.Web.CurrentUser.LoginName; } return userName; }
以上是关于sharepoint中当前登录用户的名称的主要内容,如果未能解决你的问题,请参考以下文章
SharePoint 2010使用SPServices获取用户标识
SharePoint 2013 使用 JavaScript 获取当前用户
错误:名称在当前上下文中不存在(Webpart、C#、Visual Studios、SharePoint 2010)