Pietro,
Q1. Well, the pwdProperties is only exposed by the LDAP provider (on W2K and
higher domains)
Furthermore, I strongly suggest you to use LDAP in a W2K/W2K3 AD domain
environment and use the WinNT provider ONLY to access NT4 domains and
memberserver/workstation.
Q2. //Domain is a placeholder, it can contain the IP address of the domain
controller, the DNS name of the DC or the Windows DOMAIN name .
- domain\account and pwd denotes the binding user's credentials (domain user
id and password), note that these are the credentials used to access the AD
service objects.
- dc=.., dc=..., specifies the distinguished name of the domain to bind to.
Ex. dc=microsoft, dc=com.
The distinguished name of the domain can be obtained by reading the
defaultNamingContext like this:
using(DirectoryEntry domain = new
DirectoryEntry("LDAP://RootDSE","domain\\administrator", "mySecret",
AuthenticationTypes.ServerBind ))
{
string dn = (string)domain.Properties["defaultNamingContext"].Value;
Console.WriteLine(dn);
}
Here we are binding against the users default domain (login domain).
Another possibility is to specify the domain name or DC name, that way you
can bind against any domain as long as the binding user has the necessary
access privileges.
Q3. When using C# and the framework classes to access the AD, your best bet
are the MSDN doc's, unfortunately, you have to switch back and fort between
the System.DirectoryServices FCL doc's and the platform sdk docs
(
http://msdn.microsoft.com/library/en-us/dsportal/dsportal/directory_services_portal.asp?).
The reason for this is, that System.DirectoryServices is simply wrapping the
ADSI client COM services interfaces, and most of the properties are
described in the ADSI doc's and not in the FCL doc's.
Willy.
Studio P.M. said:
Dear Mr. Denoyette,
In this way, beyond the "pwdProperties", I could equally get
"minPwdLength" and "pwdHistoryLength" too. Very acccurate, very complete,
and very kind of you.
And stimulating too. Indeed I can't refrain from asking these further
questions.
Q1) You chose the "LDAP://" provider, and not, say, the "WinNT://". Why?
Q2) I'm not familiar with LDAP, hence I must ask you to be more detailed
about all these arguments:
//Domain/ is it a keyword, or a placeholder for a real domain name?
DC=...,DC=... what is it for?
domain\\account same question: is it a keyword, or...
pwd same question
Q3) Where can I find such elusive information as that one you gave me? I
mean: is there a reference source, or book, that I could consult when you
are non here round to grant your support?
All the best, and thanks again. Yours,
Pietro Moras
- - - - -=- - - - -=- - - - -=- - - - -=- - - - -=- - - - -=
Willy Denoyette said:
3. You can read the pwd properties by binding to the root of the domain
tree
and retrieve the pwdProperties.
pwdProperties is an int, the LSB is used for DOMAIN_PASSWORD_COMPLEX
// check the platform SDK doc's for other bitflags
const int DOMAIN_PASSWORD_COMPLEX = 0x000001;
using (DirectoryEntry domain = new
DirectoryEntry("LDAP://Domain/DC=....,DC=.....,DC=....",
"domain\\account", "pwd"))
{
int pwdProps = (int)domain.Properties["pwdProperties"].Value;
Console.WriteLine(pwdProps);
}
}
Willy.