You are creating key container for that user, but trying to get it from machine-based storage. To fix the problem you need either change CRYPT_MACHINE_KEYSET
to 0 or when creating keyset use CRYPT_NEWKEYSET | CRYPT_MACHINE_KEYSET
according to your needs.
By default, keys and key containers are stored as user keys. For Base Providers, this means that user key containers are stored in the user's profile. A key container created without this flag by an administrator can be accessed only by the user creating the key container and a user with administration privileges.
For details, please check the links below.