Adding FBA Roles in bulk


This may be a very unique situation, but we are building a SharePoint solution that uses a large number of FBA roles. Currently over 350 different roles.

First, I'm struggling with the FBA Pack's FBA Role Management page. By default, it only lists three roles per page. With over 350 roles, this is a big nuisance. How can we modify this?

Second, I can't seem to find any method of exporting/importing FBA roles. There seem to be many options for exporting/importing FBA users, but roles appear to be uncharted territory.

I was able to write a PowerShell scriptlet that uses the SQL stored procedures to directly export/import users and roles in the database. Unfortunately, there is an additional step to get the users/roles into the SharePoint site. For FBA users, it's as simple as running the PowerShell command:
       New-SPUser -Web '' -UserAlias 'i:0#.f|FBAUsers|JohnSmith' -DisplayName 'John Smith'
For some reason, this method does not work for roles. When attempted like such:
       New-SPUser -Web '' -UserAlias 'c:0-.f|FBARoles|SomeRole' -DisplayName 'Some Role'
PowerShell fails to locate the 'user', even though it exists in the membership database exactly as indicated. Oddly, if you add the FBA role directly in SharePoint, the sister commandlet of New-SPUser, Get-SPUser works just fine to retrieve the role. Which just adds to the frustration.

Has there been any work done for importing FBA Roles into SharePoint in bulk? Or is our solution 'breaking ground' here?


To change the number of rows shown in Roles, you can change the value in RolesDisp.aspx:

You're right, that's totally innapropriate. I'll fix that in a future build:

You shouldn't have to do anything to add roles to SharePoint. Adding them to the membership database directly should be enough. And then they should show in the Role management page, and can be assigned to users.

Make sure when the roles are added that they:
Are being added to the same membership database used by SharePoint
Are being added with the same ApplicationName used by SharePoint (A membership database can contain multiple sets of users/roles for different applications).

As for breaking new ground, I wouldn't say you're breaking new ground, however most customers don't use roles at all and instead assign users directly to SharePoint groups.

Thank you. That is helpful.