Question

Recently two users in our system started getting this error when trying to add them to a role.

System.Runtime.InteropServices.COMException: Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7)

What is interesting is that the same error occurs regardless of the configuration, running locally we use an XML store and in the test environment it uses SQL Server.

Here is code where is blows up - AddMemberName() - as you can see this is pretty straightforward stuff and it's worked well for a while, it's just these two users all of the sudden

public void AddUserToRole(string roleName, string userName, bool upn)
{
   string uName = userName;

   if (upn)
      uName = getAltUserNames(userName).First();

   AzAuthorizationStore store = new AzAuthorizationStoreClass();
   store.Initialize(2, _provider.StoreLocation, null);
   IAzApplication app = store.OpenApplication(_provider.ApplicationName, null);
   IAzRole role = app.OpenRole(roleName, null);
   role.AddMemberName(uName, null);
   role.Submit(0, null);
   Marshal.FinalReleaseComObject(role);
}

I tried googling various different terms but can't find much of anything regarding this. I did read this post but it doesn't seem to be the issue.

Thanks

Was it helpful?

Solution

Check you Active Directory usernames and the underlying OU name especially. Check for duplicates and mismatches. I had an issue once where a user got married and her name changed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top