As I discovered during my BlogEngine upgrade, there is an effort within the project team to focus the codebase on three possible usage models on any given BlogEngine server instance:
- Single blog with a user – a personal blog (default)
- Single blog with many users – a team/company blog
- Many blogs each with a single user – a set of related blogs that can be agregated togther
I needed the third option, problem was in its history our blog has been both of the other two types, so I have multiple user accounts for each blogs, and login usernames are repeated between individual blogs on the server.
This is not fundamentally an issue for a server running in the third mode, except on the primary blog that is setup to provide agregation of all the other blogs. Even here, on a day to day basis, it is not an issue either, basic post RSS aggregation is fine. However, when you login as an administration user and try to access the dashboard you get the error
Item has already been added. Key in dictionary: 'displayname' Key being added: 'displayname'
The workaround I have used in the past was to temporarily switch off blog aggregation whenever I needed to access the primary blog dashboard – not the best solution.
After a bit of investigation of the codebase I found that this issue is due to the fact we had users called ‘admin’ on the primary and all the child blogs. The fix I used was a bit of SQL to do some user renaming from ‘admin’ to ‘adminblogname’ . I needed to rename the username in a few tables.
AS USUAL BEWARE THIS SQL, MAKE SURE YOU HAVE A BACKUP BEFORE YOU USE IT, IT WORKS FOR ME BUT I MIGHT HAVE MISSED SOMETHING YOU NEED
update p
set p.SettingValue = concat (p.SettingValue , ' ', b.BlogName)
from be\_Profiles p
inner join be\_Blogs b on
b.BlogID = p.BlogId
where
SettingName ='displayname' and
SettingValue = 'admin';
update p
set p.UserName = concat (p.UserName , b.BlogName)
from be\_Profiles p
inner join be\_Blogs b on
b.BlogID = p.BlogId
where
username= 'admin';
update u
set u.UserName = concat (u.UserName , b.BlogName)
from be\_Users u
inner join be\_Blogs b on
b.BlogID = u.BlogId
where
username = 'admin';
update r
set r.UserName = concat (r.UserName , b.BlogName)
from be\_UserRoles r
inner join be\_Blogs b on
b.BlogID = r.BlogId
where
username = 'admin';
This is not a problem specific to admin users, any username duplication will cause the same error. This basic SQL script can be modified to fix any other user accounts you might have username clashes on.
Once this SQL was run I was able to login to the dashboard on the primary blog as expected.