How to get the current user logged into Sharepoint
2011-09-19 14:34
267 查看
the following snippet get the current user lgged into Sharepoint and displays his/her Name, Login name, Email and all the groups he/she belongs to.
http://geekswithblogs.net/shervin/archive/2008/05/19/122238.aspx
try { SPWeb web = SPControl.GetContextWeb(Context); SPUser sUser = web.CurrentUser; string str = "Name:" + sUser.Name + "<BR>"; str +="Login Name :" + sUser.LoginName + "<BR>"; str +="Email:" + sUser.Email + "<BR>"; str +="Groups:" + sUser.Groups.Count + "<BR>"; foreach (SPGroup grp in sUser.Groups) { str +=" * " + grp.Name + " total Members:" + grp.Users.Count + "<BR>"; } catch (Exception ex) { messagebox.show("No Current User" ); }
http://geekswithblogs.net/shervin/archive/2008/05/19/122238.aspx
相关文章推荐
- 学习:How To Use Filters in SharePoint to show items in the current Calendar Month(转)
- How to get the full error stack trace of SharePoint
- Switch view in the InfoPath form according to the whether current user is in SharePoint group admin
- Get the SharePoint groups in Infopath 2010 and SharePoint 2010 by current user without any code
- Get tasks assigned to user or to current user groups in SharePoint using CAML query
- How to get current date time in SharePoint Site Time Zone
- Understanding the SharePoint calendar and how to export it to iCal format
- How to move the databases that are used by SharePoint Portal Server 2003 to a computer that is running SQL Server
- iOS Programming 101: How To Get the User Location in iPhone App
- How To Iterate SharePoint Attachments Using The API
- How to open MS word document from the SharePoint 2010 using Microsoft.Office.Interop.dll
- How to get to the point quickly?
- How to unlock the locked tasks in Sharepoint Workflow
- How to Integrate SAP Business Data Into SharePoint 2010 Using Business Connectivity Services and LINQ to SAP
- how to get sharepoint lookup value
- How to set the current user on the model instance in the admin:
- How to Modify the web.config file in SharePoint using SPWebConfigModification?
- How to Operate SharePoint User Alerts with PowerShell
- PHP: How to Get the Current Page URL
- How to Sign in as a Different User in SharePoint 2013