Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

DsGetDcOpen (netapi32)
 
.
Summary
The DsGetDcOpen function opens a new domain controller enumeration operation

C# Signature:

using DWORD = System.UInt32;
using ULONG = System.UInt64;

[DllImport(Netapi32, CharSet=CharSet.Auto, SetLastError=true)]
internal static extern DWORD DsGetDcOpen(
     [MarshalAs(UnmanagedType.LPTStr)]
     string DnsName,
     ULONG OptionFlags,
     [MarshalAs(UnmanagedType.LPTStr)]
     string SiteName,
     IntPtr DomainGuid,
     [MarshalAs(UnmanagedType.LPTStr)]
     string DnsForestName,
     ULONG DcFlags,
     out IntPtr RetGetDcContext
     );

For Example 1 below:

[DllImport("Netapi32.dll", EntryPoint = "DsGetDcOpenW", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
internal static extern int DsGetDcOpen(
    [In] string dnsName,
    [In] int optionFlags,
    [In] string siteName,
    [In] IntPtr domainGuid,
    [In] string dnsForestName,
    [In] int dcFlags,
    out IntPtr retGetDcContext
    );

VB Signature:

Declare Function DsGetDcOpen Lib "netapi32.dll" (TODO) As TODO

User-Defined Types:

None.

Notes:

RetGetDcContext

out Pointer to a HANDLE value that receives the domain controller enumeration context handle. This handle is used with the DsGetDcNext function to identify the domain controller enumeration operation. This handle is passed to DsGetDcClose to close the domain controller enumeration operation.

Tips & Tricks:

Please add some!

Sample Code:

    IntPtr pDcContext = new IntPtr();
    int iReturn = 0;

    // if you are getting the entire domain
    iReturn = DsGetDcOpen("domain1.mydomains.com", 0, null, (System.IntPtr)null, null, 0, out pDcContext);

    // this is a great call, it will give you all the DC's that COVER a site, not just the DC's in that site:
    iReturn = DsGetDcOpen("domain1.mydomains.com", 1, "MYADSITE", (System.IntPtr)null, null, 0, out pDcContext);

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
DsGetDcOpen on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions