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

DsGetSiteName (netapi32)
 
.
Summary
The DsGetSiteName function returns the name of the site where a computer resides. For a domain controller (DC), the name of the site is the location of the configured DC. For a member workstation or member server, the name specifies the workstation site as configured in the domain of the computer.

C# Signature:

[DllImport("NetApi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern UInt32 DsGetSiteName([MarshalAs(UnmanagedType.LPTStr)]string ComputerName, out IntPtr SiteNameBuffer);

VB Signature:

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

User-Defined Types:

None.

Alternative Managed API:

None

Notes:

The DsGetSiteName function does not require any particular access to the specified domain. The function is sent to the Netlogon service on the computer specified by ComputerName.

Return codes:

ERROR_NO_SITENAME The computer is not in a site.

ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.

Tips & Tricks:

Please add some!

Sample Code:

IntPtr pBuffer = IntPtr.Zero;

UInt32 result = DsGetSiteName(ComputerName, out pBuffer);

if (result == 0)

{

    String sSiteName = Marshal.PtrToStringAuto(pBuffer);
    NetApiBufferFree(pBuffer);

}

Documentation

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
Find References
Show Printable Version
Revisions