How to convert this display name to SPUser type.
My input is Sivakumar, Piratheban (ext)(domain\user)
How to convert this display name to SPUser type.
My input is Sivakumar, Piratheban (ext)(domain\user)
There is no direct convertion but you can use a regular expression to pull out the login name and then call EnsureUser on that.
var login = Regex.Match(input, @"\((?<login>[^\(\\]+\\[^\(\\]+)\)$", RegexOptions.ExplicitCapture).Groups["login"].Value;
var user = web.EnsureUser(login);
You could extract login name from input string using String.Split Method and then initialize a user:
var loginName = input.Split('(', ')')[3];
var user = web.EnsureUser(loginName);