跳至主要内容

WebPart: 显示登录用户名

以下均在RenderWebPart函数中:
 
首先获取SPWeb
SPWeb myweb = SPControl.GetContextWeb(this.Context);
也是无意中发现SPWeb提供了CurrentUser的方法,因此可以通过
myweb.CurrentUser.Name得到用户显示名,而不是Login名,同时还可以获得的有Email,Alerts等信息。
 
要得到Login名,可以这么做:
IPrincipal user = this.Context.User;
调用user.Identity.Name()便可以返回登录用户名
 
之前就想写一个简单的WebPart交差了事,没想到这种简单功能的WebPart也颇费周折。
1. 网上居然没有找到现成的代码,大多是卖的,或是提供cab安装包。
2. WSS的帮助也是非常难看,只能作参考,不能作入门,手头的几本电子书也是讲得非常浅,甚至就不提WebPart开发。
3. WSS的权限设置实在是太麻烦了!!!反正这个assembly仅仅拷到Bin在web.config里加Trust不行,我是拷到GAC里去,管它什么安全问题,没把外人拦着,把自己倒挡在外面了。

评论

此博客中的热门博文

反转剧

这两天明显感到天气转冷,呱呱的家里也已经下起了大雪,南京则是阴冷潮湿,让人没有了出行的欲望。没想到躲在被子里看反转剧也成了度过寒冬的一剂良药。在PPLive越来越让人失望的时候,PPStream横空出世,虽然广告仍是少不了的主题,但从视频质量和播放连续性上来说都超过PPLive,实为居家必备之良品(由此可见,新事物一定会战胜旧事物......)。韩国的反转剧最近似乎比较流行,称之为反转剧就在于其结果总是让人出乎意料,不合常理,其间又不乏各种搞怪搞笑的镜头,各种当红帅哥美女也一定让DDMM们爱不释手,20~30分钟一集的剧情一改韩剧拖沓的风貌,想看就看,容易切入。 反转剧,今天你看了吗?

from cpp to java

when i start to study java with a cpp background, i find it is very difficult to convert my mind. i always think how some features in cpp was implemented in java, this give me a little reject to java language. though java is born from c, i think they still have different applicable domains, so try to study both is good for me, and java is a pure OO language, i believe it will give me a better understanding on OOD.

Personalized Google Home

Using your google account, you can create a personalized homepage. You can customize several modules, including various news, gmail, bookmarks. This service is similar to what http://www.netvibes.com/ provides. The drawback is the inconvenience of bookmark module. It doesn't provide grouping while netvibes provide tags to implement this. Wishing google will improve this defect in the near future. Meanwhile, the Live plan of Microsoft is also going on. MS presents several several servicies to counterattack google's counterparts. Virtual Earth (see http://preview.local.live.com ) is a recent service. It provides map service just like google earth, provides a virtual tour better than google. Imaging driving a car in the map and seeing everything real, maybe you can do a virtual europe tour now. Seems interesting. MS also provides a customized home, you can log into www.live.com via your msn accounts. I haven't tried that yet.