Accessing an AD Group

G

Guest

The below works when the first parameter to DirectoryEntry is set to our
corporate AD domain, such as LDAP://FORD. But if I try for a group within
the domain, such as LDAP://FORD/TRUCKS, I get the error message
"an invalid dn syntax has been specified".
What is the syntax to look at a group?
Thanks, Mark

adEntry = new DirectoryEntry(corpDomain, "SE0017", "IAMsense1",
AuthenticationTypes.Secure);
adSearch = new System.DirectoryServices.DirectorySearcher(adEntry);
adSearch.Filter = ("(anr="+userAccount+")");
try
{
adResult=adSearch.FindOne();
searchCount = adResult.Properties.Values.Count;
}

The below works when the first parameter (cordDomain) to DirectoryEntry is
set to our corporate AD domain, such as LDAP://FORD. But if I try for a
group within the domain, such as LDAP://FORD/TRUCKS, I get the error message
"an invalid dn syntax has been specified".
What is the syntax to look at a group?
Thanks, Mark

adEntry = new DirectoryEntry(corpDomain, "SE0017", "IAMsense1",
AuthenticationTypes.Secure);
adSearch = new System.DirectoryServices.DirectorySearcher(adEntry);
adSearch.Filter = ("(anr="+userAccount+")");
try
{
adResult=adSearch.FindOne();
searchCount = adResult.Properties.Values.Count;
}

P.S. "FORD" is just being used for an example.
 
W

Willy Denoyette [MVP]

Please consult the AD/ADSI documentation is MSDN for the correct AD or LDAP
syntax before you start using DirectoryServices.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top