Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need get a list of Whencreate object and user in ldap with C#,
in this code i cat list, all of user in ldap but i need get Whencreate option all of user and object.

Code:

C#
//ActiveDirectorySearch1
//Displays all computer names in an Active Directory
using System;
using System.DirectoryServices;
namespace ActiveDirectorySearch1
{
    class Class1
    {
        static void Main(string[] args)
        {

            //Note : microsoft is the name of my domain for testing purposes.
            string ldap_server = ("LDAP://dc=myserver,dc=com");
            DirectoryEntry entry = new DirectoryEntry(ldap_server);
            DirectorySearcher mySearcher = new DirectorySearcher(entry);
            mySearcher.Filter = ("(objectClass=user)");
            
            Console.WriteLine("Listing of computers in the Active Directory"); 
            Console.WriteLine("============================================"); 
            int conter = 0;
            foreach(SearchResult resEnt in mySearcher.FindAll())
            { 
                Console.WriteLine(resEnt.GetDirectoryEntry().Name.ToString());
                conter++;
            }
            Console.WriteLine(conter);
            Console.WriteLine("=========== End of Listing ============="); 
                        
        }
    }
}
Posted
Updated 4-Jun-12 18:03pm
v3

1 solution

You can access it wia http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.properties[^] property collection.
C#
...
foreach(SearchResult resEnt in mySearcher.FindAll())
{ 
	DirectoryEntry ent = resEnt.GetDirectoryEntry();
	Console.WriteLine("{0} created on {0}", ent.Name, ent.Properties["WhenCreated"].Value.ToString());
	
	conter++;

}
...
 
Share this answer
 
Comments
Bevin wc 12-Oct-17 8:13am    
Can someone help me with this ? https://www.codeproject.com/Questions/1210193/Search-users-by-filtering-using-whencreated-in-act

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900