sharepoint获取域名和当前登录的应为名字
protected void Page_Load(object sender, EventArgs e)
{
string a = SPContext.Current.Web.CurrentUser.ToString();
int length = a.IndexOf("w|", 0) + "w|".Length; //获取字符串长度
int IndexofA = a.IndexOf("\\", length); //结束位置 ;//获取出现的位置
string DomainName = a.Substring(length, IndexofA - length);//获取域名就是字符串中间的字
int f = a.IndexOf("\\");
string Name = a.Substring(f + 1);//获取名字
this.Label1.Text = Name;
txtdomain.Text = DomainName+".com";//域名
}

浙公网安备 33010602011771号