PC Review


Reply
Thread Tools Rate Thread

Cannot Single out one Property using System.DirectoryServices

 
 
=?Utf-8?B?bWJvd2Vyc294?=
Guest
Posts: n/a
 
      24th May 2005
Hello,

I'm trying to use the System.DirectoryServices namespace with C# in order to
connect to our Novell eDirectory tree and get some information. The problem
I am encountering is that when I explicitly want to pull out the surname for
instance, I am still retrieving every entry for that user. If anyone can
take a look at the following code and point me in the correct direction:

using System;
using System.DirectoryServices;

namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
DirectoryEntry mainEntry = new DirectoryEntry( "LDAP://10.0.0.30" );
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher( mainEntry );
mySearcher.Filter = "(sn=bow*)";
mySearcher.PropertiesToLoad.Add( "cn" );
mySearcher.PropertyNamesOnly = true;
System.DirectoryServices.SearchResultCollection resCollection =
mySearcher.FindAll();
foreach(System.DirectoryServices.SearchResult resEnt in resCollection )
{
DirectoryEntry thisEntry = resEnt.GetDirectoryEntry();
foreach( string propName in thisEntry.Properties.PropertyNames )
{
try
{
foreach( object propValue in thisEntry.Properties[propName] )
{
Console.WriteLine( propName + ": " + propValue );
}
}
catch( System.Runtime.InteropServices.COMException e )
{
System.Console.WriteLine( "Exception Encountered...Continuing..." );
continue;
}
}
}
}
}
}

Any help would be greatly appreciated as I'm pretty stuck on this one and
feel I am doing it correctly. Thanks in advance!

-Mike
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DirectoryServices and ObjectClass property Jeroen Microsoft C# .NET 4 22nd May 2007 06:20 PM
DirectoryServices Property Update Davie Microsoft Dot NET 1 5th Jul 2006 09:43 PM
DirectoryServices Update AD property Davie Microsoft ASP .NET 2 1st Jun 2006 09:24 AM
System.DirectoryServices ProxyAddresses property =?Utf-8?B?Qm9uaQ==?= Microsoft Dot NET Framework 2 20th Jul 2005 07:30 AM
DirectoryServices : pb with property memberOf BlackGoddess Microsoft Dot NET Framework 6 29th Jul 2004 10:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:40 AM.