I tried to update Person column with C#. NT AUTHORITY\authenticated users in the site have read permission at site site level. Sometimes when the code try to find user by login id from web.AllUsers["login id"] it throws an SPException "User cannot be found". How can I fix this mess?
Adding all authenticated users does not mean they are getting to the site. Yes, they have permission to site but if you check the User Information List of the site, they cannot be found there.
When you call web.AllUsers, it checks in the user information list. Since the user is not there, it can cause error. There are scenarios where SharePoint put into this list by itself.
The solution to this is using the
Ensure that the user you are trying to add exist in the web site. You can make use of EnsureUser() function of the SPWeb object.
You may write your code as:
On MSDN article you can learn more about EnsureUser() function.
Hope this helps.