Print Page | Close Window

Authenticating against Active Directory

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1545
Printed Date: 23-Apr-2024 at 4:20am


Topic: Authenticating against Active Directory
Posted By: btitular
Subject: Authenticating against Active Directory
Date Posted: 05-Nov-2009 at 3:09pm

Does anyone have a sample of a silverlight client app authenticating against an active directory? I've found a few articles on MSDN that demonstrate that it's possible, but I'm a little lost as to how to accomplish this with the DevForce LoginAsync() method.




Replies:
Posted By: btitular
Date Posted: 05-Nov-2009 at 5:33pm

I was able to get the authentication working with active directory.

Here were the references that I used:

http://msdn.microsoft.com/en-us/library/ms998360.aspx - http://msdn.microsoft.com/en-us/library/ms998360.aspx
http://blog.jumptree.com/2008/active-directory-and-aspnet-forms-authentication - http://blog.jumptree.com/2008/active-directory-and-aspnet-forms-authentication

In the web.config file, the following modifications were made:

1. In the connectionStrings element, I added:

    <add name ="ADConnectionString"
         connectionString=" ldap://mydomain.com/DC=mydomain,DC=com/ - LDAP://mydomain.com/DC=mydomain,DC=com"/ >

    where mydomain would be your own domain name.
 
2. In the system.web element, the following were added:

 <authentication mode="Forms">
       <forms name=".ADAuthCookie"
              timeout="10"/>
 </authentication>

  
 <membership defaultProvider="MyADMembershipProvider">
       <providers>
         <add name="MyADMembershipProvider"
              type="System.Web.Security.ActiveDirectoryMembershipProvider,
              System.Web, Version=2.0.0.0,
              Culture=neutral,
              PublicKeyToken=b03f5f7f11d50a3a"
              connectionStringName="ADConnectionString"
              connectionUsername="yourusername"
              connectionPassword="yourpassword"
              attributeMapUsername="sAMAccountName"/>
       </providers>
 </membership>

where yourusername is a valid user that can access the active directory and yourpassword is the corresponding password for that user.

The key item for me to get it working correctly was that my user's don't have to enter a domain name. In order for the authentication to work, I had to add the:

 attributeMapUsername="sAMAccountName"

to the providers element.



Posted By: GregD
Date Posted: 06-Nov-2009 at 3:10pm
Thanks for posting that, btitular.  That should be helpful to other users trying to do the same.



Print Page | Close Window