Tag Info

New answers tagged

2

You can't compare Reference objects unless they implement IEquatable interface. Or it should override equal method with custom implementation. I would suggest you compare SPUser.LoginName instead.


0

I had to convert a possible Claims Authentication name format back to DOMAIN\USER format to run EnsureUser. Seems EnsureUser will work with the claims format for existing users that have accessed the site, but not new users. This code sample gets the email address for a user by first checking if the provided name is in claim format and converts it to ...


2

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);


3

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);



Top 50 recent answers are included