Export (0) Print
Expand All

IADsADSystemInfo::GetAnyDCName method

The IADsADSystemInfo::GetAnyDCName method retrieves the DNS name of a domain controller in the local computer's domain.

Syntax


HRESULT GetAnyDCName(
  [out]  BSTR *pszDCName
);

Parameters

pszDCName [out]

Name of a domain controller, such as "ADServer1.domain1.Fabrikam.com".

Return value

This method supports the standard HRESULT return values. For more information, see ADSI Error Codes.

Examples

The following C++ code example retrieves the Windows system information. For brevity, error checking is omitted.


#include <activeds.h>
#include <stdio.h>
 
int main()
{
   HRESULT hr;
 
   hr = CoInitialize(NULL);
 
    IADsADSystemInfo *pSys;
    hr = CoCreateInstance(CLSID_ADSystemInfo,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IADsADSystemInfo,
                          (void**)&pSys);
 
   BSTR bstr;
   hr = pSys->GetAnyDCName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("Domain controller: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   if(pSys) {
      pSys->Release();
   }
 
   CoUninitialize();
   return 0;
}

The following Visual Basic code example uses the IADsADSystemInfo::GetAnyDCName method to retrieve the name of the Active Directory domain controller.

Dim sys As New ADSystemInfo
Debug.Print "Domain Controller: " & sys.GetAnyDCName

The following VBScript/ASP code example uses the IADsADSystemInfo::GetAnyDCName method to retrieve the name of the Active Directory domain controller.

<%
Dim sys
Set sys = Server.CreateObject("ADSystemInfo")
Response.Write "Domain Controller: " & sys.GetAnyDCName
%>

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Iads.h

DLL

Activeds.dll

IID

IID_IADsADSystemInfo is defined as 5BB11929-AFD1-11D2-9CB9-0000F87A369E

See also

IADsADSystemInfo
ADSI Error Codes

 

 

Show:
© 2014 Microsoft