本文介绍了如何获得"whencreat" C#中选择Active Directory中的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我需要使用C#在ldap中获取Whencreate对象和用户的列表,
在此代码中,我列出了ldap中的所有用户,但我需要同时获取所有用户和对象的whencreate选项.

代码:

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:

//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 =============");

        }
    }
}

推荐答案

...
foreach(SearchResult resEnt in mySearcher.FindAll())
{
	DirectoryEntry ent = resEnt.GetDirectoryEntry();
	Console.WriteLine("{0} created on {0}", ent.Name, ent.Properties["WhenCreated"].Value.ToString());

	conter++;

}
...


这篇关于如何获得"whencreat" C#中选择Active Directory中的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 00:11