Re: Error setting DirecotrySearcher's new ExtendedDN



ExtendedDN only works on Windows 2003 machines and higher. It doesn't work
on XP (if yo are using it via ADSI, which S.DS does). Is your machine XP or
lower?

BTW, you didn't show the exception...

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Pucca" <Pucca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:84B87E31-7443-41E2-862E-30D0757092AB@xxxxxxxxxxxxxxxx
Hi, I'm developeing with VS2005 and .Net 2.0 and C#. I'm trying to set
the
DirecotrySearcher's new ExtendedDN property but I keep getting the
following
error when my code reaches "using (SearchResultCollection results =
srch.FindAll())". I don't get any error at the code of setting the
prooperty
though, "srch.ExtendedDN = ExtendedDN.Standard;" Can anyone see what I
need
to correct here? Thanks.

public string GetWinName(DirectoryEntry de, DirectoryEntry
deParent)
{
string sidKey = null, childSidKey = null, sid = null;
int lastDash = 0;
childSidKey = de.Properties["cn"].Value.ToString();

de.AuthenticationType = AuthenticationTypes.FastBind |
AuthenticationTypes.Secure;

DirectorySearcher srch = new DirectorySearcher(deParent);

srch.SearchScope = SearchScope.OneLevel;
srch.Filter = ("(objectClass=meeting)");

srch.PropertiesToLoad.Add("distinguishedName");

/* Instruct the DirectorySearcher to use the
* new ExtendedDN enumeration to return either
* the standard format or hex format for the
* distinguishedName. In this case, dnFormat
* is a ExtendedDN type parameter passed into
* the function.
*/
srch.ExtendedDN = ExtendedDN.Standard;

using (SearchResultCollection results = srch.FindAll())
{
foreach (SearchResult res in results)
{
String extDn =
res.Properties["distinguishedName"][0].ToString();
String[] dnParts = extDn.Split(new char[] { ';' });

--
Thanks.


.


Quantcast