开发者

listing unsecured shared folders on windows

//ActiveDirectorySearch1
//Displays all computer names in an Active Directory
using System;
using System.DirectoryServices;

namespace ActiveDirectorySearch1
{
    class Class1
    {
       static void Main(string[] args)
       {

           DirectoryEntry entry = new DirectoryEntry("LDAP://pune");
           DirectorySearcher mySearcher = new DirectorySearcher(entry);
           mySearcher.Filter = ("(objectClass=computer)");
           Console.WriteLine("Listing of computers in the Active Directory");
           Console.WriteLine("============================================");       开发者_JS百科                     

           foreach(SearchResult resEnt in mySearcher.FindAll())
           {
               Console.WriteLine(resEnt.GetDirectoryEntry().Name.ToString()); }
               Console.WriteLine("=========== End of Listing =============");
               Console.ReadKey();
           }
       }
   }
}

now i just want to list all unsecured shared folders ..what do i do ?


If your AD is pre Windows Server 2008, you should really change your filter to (&(objectCategory=computer)(objectClass=computer)). This will take advantage of indices in the database and be much more efficient.

As to getting Shares, I've used Win32_Share before. You can use mgmtclassgen to build a strongly typed wrapper that's pretty easy to work with.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜