sharepoint获取域名和当前登录的应为名字

时间:2022-04-16 19:19:35

string a =  SPContext.Current.Web.CurrentUser.ToString();

int length = a.IndexOf("w|", 0) + "w|".Length; //获取字符串长度
int IndexofA = a.IndexOf("\\", length); //结束位置 ;//获取出现的位置
string b = a.Substring(length, IndexofA - length);//获取域名就是字符串中间的字

int f = a.IndexOf("\\");
string s = a.Substring(f+1);//获取名字