In a timer job I added users to a certain SPGroup and added this group to some libraries with contribute rights. When I logged is with that user account it didn’t have the contribute rights. The problem was that the Windows account was added instead of the claims based user.
At first I just used the following code:
However this added a user as formatted in this XML:
I changed it to look for the correct SPUser using this code snippet:
This will generate a claim that represents the windows account “SP2010\user1”. This will find the correct SPUser, the XML is:
Notice the formatting of the LoginName.
Now the correct user account (in claims format) is added to the library with contribute rights the user logging in with SP2010\user1 can contribute.