Groups > Asp .Net > ASP dotNET Security > Re: LDAP connectionStrings Active Directory Forms Auth




LDAP connectionStrings Active Directory Forms Auth

LDAP connectionStrings Active Directory Forms Auth
Tue, 1 Apr 2008 17:23:22 +0000
Hello,

I am not that familiar with using LDAP, Active Directory, and Forms Auth.  I am
trying to move from using Windows Auth to Forms with Active Directory.

How do I know what to put into my LDAP connectionString?

Thanks Matt
Post Reply
Re: LDAP connectionStrings Active Directory Forms Auth
Tue, 1 Apr 2008 18:21:47 +0000
You should be able to view all the LDAP connection stings on your network using
the System.DirectoryServices namespace.  Just keep in mind some properties in
the LDAP could be different depending if some were removed, changed, etc.  I
listed some of the basic ones. 

using System;

using System.Collections.Generic;

using System.Text;

using System.Security.Principal;

using System.Web;

using System.DirectoryServices;namespace WindowsUserAccount

{

classProgram

{staticvoid Main(string[] args)

{

DirectoryEntry de = newDirectoryEntry();DirectorySearcher ds =
newDirectorySearcher(de);

////can add filters like this

//ds.Filter = "(CN=*Joseph*)";SearchResultCollection results =
ds.FindAll();

 foreach (SearchResult result in results)

{

////shows all the LDAP paths

//Console.WriteLine(result.Path);foreach (string propKey in
result.Properties.PropertyNames)

{

// Display each of the values for the property 

// identified by the property name.foreach (object property in
result.Properties[propKey])

{if (propKey == "cn")

if(property.ToString().Length < 35)Console.WriteLine(":",
propKey, property.ToString());

}

}

}

//sAMAccountName – user ID of the account created (Note, when programmatically
creating/adding users – you have control over this field – but not after the
object has been added). 

//name – same value as the sAMAccountName property. 

//givenName – First Name of the user. 

//sn – or Sur Name – Last Name of the User 

//displayName – typically, the same as the name, and sAMAccountName 

//userPrincipalName – the same as name, sAMAccountName 

//co – Country 

//mail – single email address value (I’ll demonstrate how we can maintain
multiple emails in another Part). 

//telephoneNumber – User’s phone number 

//description – A description of this account 

//userAccountControl – The enumerated property that we’ll use to manage the
user’s account – access, password change, locked, and others. 

//wWWHomePage – User’s default homepage –optional. 

//parent – Parent owner object. For example, the name of the OU the user
account is in. 

//cn – Cononical – or Common Name – usually the combination of givenName +
sn (NOTE: If you have migrated from another system, like NT4 to AD 2000 – this
value is the same as the name, sAMAccountName, and displayName – by default,
and it cannot be changed)

}

}

}
Post Reply
about | contact