SharePoint中如何获得当前用户的loginName

<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
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

 

原文首发:http://anforen.5d6d.com/thread-158-1-1.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值