zoukankan      html  css  js  c++  java
  • 获取MOSS当前登录用户信息

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Microsoft.SharePoint;
    using Microsoft.Office.Server;
    namespace 获得当前用户
    {
       
    public partial class GetEmployee : System.Web.UI.UserControl
        {
           
    protected void Page_Load(object sender, EventArgs e)
            {
                SPSite spSite
    = new SPSite("moss的站点地址");

                SPWeb web
    = spSite.RootWeb;
               
    string userName = web.CurrentUser.Name;

                txtEmployee.Value
    = userName;
            }
        }
    }

    web.currentuser   这个有很多当前用户的属性   想要显示那个就用那个属性

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI.WebControls.WebParts;
    using System.Security.Principal;

    namespace Test
    {
       
    public class DomainUser : WebPart
        {
           
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
            {
               
    //获取当前登陆用户的登陆名  
                WindowsPrincipal wp = (WindowsPrincipal)System.Threading.Thread.CurrentPrincipal;
               
    string wpname = wp.Identity.Name.ToString();
               
    int j = wpname.LastIndexOf("\\");
               
    string userName = wpname.Substring(j + 1);
               
    string domainName = wpname.Substring(0, j);
                writer.Write(domainName.ToString()
    + " \\ " + userName.ToString());
            }
        }
    }


    string strUserName = this.Page.User.Identity.Name;

  • 相关阅读:
    python 性能测试
    python calendar
    python datetime
    Zookeeper的功能以及工作原理
    ADB 源码分析(一) ——ADB模块简述【转】
    ADB模块源码分析(二)——adb server的启动
    C/C++中的预编译指令
    开启andriod手机的adbd,进行无线adb调试
    adb和adbd详尽分析
    adb client, adb server, adbd原理浅析(附带我的操作过程)
  • 原文地址:https://www.cnblogs.com/JustSoSo/p/1207656.html
Copyright © 2011-2022 走看看