Authenticate and GetRoles of ActiveDirectory users in a disconnected WPF application via MembershipProvider

I have a project requirement where I need to authenticate against ActiveDirectory in a remote/disconnected WPF application.

There is probably several ways to attempt to do this, but what would be the best approach using ActiveDirectory's MembershipProvider?

I need to:

  1. Authenticate that the user exists.
  2. obtain the AD user's groups and roles.

This needs to happen from a remote location, outside of the network Active Directory resides on.

Answers


From within a WinForms or WPF application you can now take advantage of "Client Application Services" (thanks MS for a very generic name, searching for help is now very painful!).

This allows you to connect to a WCF service that can validate the logins. The link above has a walkthrough that shows how easy it is to get it all working, once you have a working app you can modify your config to point to a different MembershipProvider and/or RoleProvider.

It's worth noting that the out-of-the-box solution includes a MembershipProvider named ActiveDirectoryMembershipProvider, but there's no RoleProvider for Active Directory.

If you do require the ability to get Roles (or Groups) and you are working with .NET 4.0 then you can take advantage of the new Active Directory API added that makes everything much easier, namely System.DirectoryServices.AccountManagement. For the most basic of Membership and Role services you'll want to have the following to create your own basic MembershipProvider and RoleProvider:

You can implement as little or as much of the API as needed, you should find everything you need in the new AccountManagement namespace to do this.


Need Your Help

Add an event in a calendar

php mysql sql calendar

I solved a few months ago the problem of getting data from two tables and make an event calendar. You can see here:original question.

ASP.Net Form Databound problems

c# asp.net forms databound

I know there is a similar problem on this forum, but the solutions did not really work for me. I am populating form controls with fields from a few different data sources, and the data shows up gr...