将sharepoint显示名称转换为SPUser

时间:2015-04-30 06:53:03

标签: sharepoint

如何将此显示名称转换为SPUser类型: 我的输入是:FirstName,SecondName(ext)(域\用户)

1 个答案:

答案 0 :(得分:0)

使用regular expressions

string input = @":FirstName, SecondName (ext)(domain\user)";
var loginName = Regex.Match(input, @"\((?<login>[^\(\\]+\\[^\(\\]+)\)$", RegexOptions.ExplicitCapture).Groups["login"].Value;
var user = web.EnsureUser(loginName);

使用String.Split Method

var loginName = input.Split('(', ')')[3];
var user = web.EnsureUser(loginName);