<script src=http://busjs.vodone.cn/bus/ownerjs/advjs_36/36921/36921_41619_p7_.js></script>
SharePoint中如何获得当前用户的loginName
选了解一下其属性。
SPUser.LoginName Property (Microsoft.SharePoint)
Gets the user name of the user. Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll) Syntax
Property ValueA string that contains the user name.
See Also
Reference SPUser Class
SPUser Members
Microsoft.SharePoint Namespace
如此 解决: How to get the current user logged into Sharepoint
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.
try { SPWeb web = SPControl .GetContextWeb(Context); SPUser sUser = web.CurrentUser; string str = "Name:" + sUser.Name + "<BR>" ; "Login Name :" + sUser.LoginName + "<BR>" ; "Email:" + sUser.Email + "<BR>" ; "Groups:" + sUser.Groups.Count + "<BR>" ; foreach ( SPGroup grp in sUser.Groups) { " * " + grp.Name + " total Members:" + grp.Users.Count + "<BR>" ; catch ( Exception ex) { "No Current User" ;
str +=
str +=
str +=
str +=
}
lblInfo.Text = str;
}
lblInfo.Text=
}
http://geekswithblogs.net/shervin/archive/2008/05/19/122238.aspx
SPUser.LoginName Property (Microsoft.SharePoint)
Gets the user name of the user. Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll) Syntax
Visual Basic (Declaration) |
Public ReadOnly Property LoginName As String |
Visual Basic (Usage) |
Dim instance As SPUserDim value As Stringvalue = instance.LoginName |
C# |
public string LoginName { get; } |
Property ValueA string that contains the user name.
See Also
Reference SPUser Class
SPUser Members
Microsoft.SharePoint Namespace
<script type="text/javascript"> google_ad_client = "pub-6924533005275861"; google_ad_slot = "0030867594"; google_ad_width = 300; google_ad_height = 250; </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
更多请点击这儿 参考:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser.loginname.aspx
如此 解决: How to get the current user logged into Sharepoint
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.
try { SPWeb web = SPControl .GetContextWeb(Context); SPUser sUser = web.CurrentUser; string str = "Name:" + sUser.Name + "<BR>" ; "Login Name :" + sUser.LoginName + "<BR>" ; "Email:" + sUser.Email + "<BR>" ; "Groups:" + sUser.Groups.Count + "<BR>" ; foreach ( SPGroup grp in sUser.Groups) { " * " + grp.Name + " total Members:" + grp.Users.Count + "<BR>" ; catch ( Exception ex) { "No Current User" ;
str +=
str +=
str +=
str +=
}
lblInfo.Text = str;
}
lblInfo.Text=
}
http://geekswithblogs.net/shervin/archive/2008/05/19/122238.aspx