We use federated authentication and for each user we create a User item (extended from ContentBase). In the SecurityTokenValidated context, if the User item is not available, we need to create new User item.
IContentRepository contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();OurUser newUser = contentRepository.GetDefault<OurUser>(ourUserContainer);//Set some properties to new User contentRepository.Save(newUser, SaveAction.Publish); // Goes to HTTP Error 404In the server error: Logon User is Anonymous.
How can we save the new User content in the OWIN SecurityTokenValidated context?
Use this -
contentRepository.Save(newUser, SaveAction.Publish, AccessLevel.NoAccess););
I figured the issue, Save just worked fine after assigning a value to newUser.Name property. So it was not any access rights issue but Name is like a mandatory property to save a content. It is bit silly I didn't realise it, but the access denied error just freaked me at first place. Thanks