BlogEngine.net and Active Directory membership provider woes

We wanted our blog to use the user credentials found in our company's Active Directory, so after a little bit of web surfing we found a great little extension here. After going through the steps needed to install this extension we launched our webbrowser to test our updated blog...

Error: 'Unable to cast object of type 'System.Security.Principal.SecurityIdentifier' to type 'System.Security.Principal.NTAccount'

After some debugging we found out it had something to do with the GetRolesForUser() function found in the file ADRoleProvider.cs. Apperently something goes wrong when translating the token groups to the NTAccount-type. Knowing the cause of the problem, the solution was easy. Replace the foreach loop in the GetRolesForUser() function with:

foreach (IdentityReference group in groupCollection)
{
    if (group.Value.IndexOf(@"\") == -1)
    {
        // Skip groups not containing backslash
        continue;
    }

    String roleName = RGConfig.getRole(group.Value.Substring(group.Value.IndexOf(@"\") + 1));

    if (roleName != String.Empty)
    {
        roles.Add(roleName);
    }
}

After this little tweak the extension from rafekemmis worked!

Download: ActiveDirectoryRoleProvider.zip (5.39 kb)

Tags: , , , , ,

Comments

Joel D
11/25/2009 1:12:46 AM Permalink

Thank you for the posting. Do you have or can you tell me where I can find the instruction for installing and configuring ActiveDirectoryRoleProvider
Thank you.

Gravura Bucuresti Romania
9/1/2010 5:09:24 PM Permalink

Hey everyone. Interesting idea for a blog. I have been checking out a lot of blogs and forums recently. Some are really informative some are entertaining and some are a real crack up. I've got to admit it, good job on this blog, I'll be sure to look in again real soon.

Canadian Coin Prices United States
9/3/2010 9:50:21 AM Permalink

One thing I like about blog articles is the fact that they trigger an idea in my head. When that happens, I feel like I have to comment wishing it may be beneficial to others. Since there are numerous blogs with many points of view, they question your comprehension. It's at these occasions when you have good insignt many others might not have had, together with the blogger him/herself. I find myself coming back to to your blog mainly because you have several tremendous insights and also you are actually at this a very long time, that is very exciting and tells me you know a lot. Keep sparking imagination in others!

tweet attacks United States
9/4/2010 5:35:30 AM Permalink

I have noticed the quality of your blog which template are you currently using?

Nude Chat United States
9/4/2010 9:30:19 AM Permalink

cool website, I'm very happy I stumbled here through my friend's blog, going to definitely need to add another one to the old bookmark list.

the best toning shoes United States
9/5/2010 7:36:28 AM Permalink

You know you have a really cool site when you throw up stuff like this and everyone notices.  Thanks for all your hard work and all your posts.  Keep it up and keep on rocking!

google seo United States
9/5/2010 4:43:59 PM Permalink

Hey cool blog, just wondering what anti-spam software you use for comments because i get lots on my blog. Anyway, in my language, there are not much good source like this.

Thank you for sharing with us,I too always learn something new from your post!
Great article. I wish I could write so well.

so dep United States
9/5/2010 5:08:01 PM Permalink

Hey cool blog, just wondering what anti-spam software you use for comments because i get lots on my blog. Anyway, in my language, there are not much good source like this.

web page United States
9/6/2010 9:55:58 AM Permalink

Appreciation for yet another excellent post. I've got a presentation next month, and I am on the search for such important information.

asdfpoiu Japan
9/7/2010 9:17:24 AM Permalink

asdfpoiu

asdfpoiu Albania
9/8/2010 12:32:35 AM Permalink

asdfpoiu

online bingo United States
9/8/2010 11:56:53 PM Permalink

How long did it take you to get this much traffic on your site

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading