• DirectorySearcher 示例


    面的代码示例说明如何搜索域中的所有用户。它包含一些基本的必需任务,例如使用 C# try-catch 或 Visual Basic .NET try-catch-finally 语句捕捉错误以及可由 DirectorySearcher 对象引发的所有错误的错误处理。

    try
    {
    // Bind to the users container.
    DirectoryEntry entry = new DirectoryEntry("LDAP://CN=users,DC=fabrikam,DC=com");
    // Create a DirectorySearcher object.
    DirectorySearcher mySearcher = new DirectorySearcher(entry);
    // Create a SearchResultCollection object to hold a collection of SearchResults
    // returned by the FindAll method.
    SearchResultCollection result = mySearcher.FindAll();
    // Get search results. For more information, see Getting Search Results.
    // ...
    // This sample uses Try...Catch to catch errors.
    // Create an Exception object. For more information, see System.Exception.
    }
    catch (System.Runtime.InteropServices.COMException)
    {
    System.Runtime.InteropServices.COMException exception = new System.Runtime.InteropServices.COMException();
    Console.WriteLine(exception);
    }
    catch (InvalidOperationException)
    {
    InvalidOperationException InvOpEx = new InvalidOperationException();
    Console.WriteLine(InvOpEx.Message);
    }
    catch (NotSupportedException)
    {
    NotSupportedException NotSuppEx = new NotSupportedException();
    Console.WriteLine(NotSuppEx.Message);
    }
    
  • 相关阅读:
    Windows 代码实现关机(直接黑屏)
    Windows SEH学习 x86
    Smali 语法文档
    SIOCADDRT: No such process
    Windbg 常用命令整理
    ida GDB 远程调试
    IDA 使用技巧
    Windows X64 Patch Guard
    C 和C++ 名称修饰规则
    【转载】 硬盘主引导记录(MBR)及其结构详解
  • 原文地址:https://www.cnblogs.com/timy/p/1424118.html
Copyright © 2020-2023  润新知