다음을 통해 공유


IADsADSystemInfo::GetDCSiteName 메서드(iads.h)

IADsADSystemInfo::GetDCSiteName 메서드는 로컬 컴퓨터가 포함된 Active Directory 사이트의 이름을 검색합니다.

구문

HRESULT GetDCSiteName(
  [out] BSTR szServer,
  [in]  BSTR *pszSiteName
);

매개 변수

[out] szServer

Active Directory 사이트의 이름입니다.

[in] pszSiteName

서비스 서버의 DNS 이름입니다.

반환 값

이 메서드는 표준 HRESULT 반환 값을 지원합니다. 자세한 내용은 ADSI 오류 코드를 참조하세요.

설명

Active Directory 사이트는 Active Directory 도메인 컨트롤러를 보유하는 하나 이상의 잘 연결된 TCP/IP 서브넷입니다. 자세한 내용은 Active Directory 핵심 개념을 참조하세요.

예제

다음 C++ 코드 예제에서는 Active Directory 사이트 이름을 검색합니다. 간단히 하기 위해 오류 검사는 생략됩니다.

#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 siteName;
   BSTR dnsServer;
   hr = pSys->GetAnyDCName(&dnsServer);

   if (SUCCEEDED(hr)) {
      printf("Domain controller: %S\n", dnsServer);

      hr = pSys->GetDCSiteName(&siteName);
      if (SUCCEEDED(hr)) {
          printf("Domain controller site: %S\n", siteName);
          SysFreeString(siteName);
      }

      SysFreeString(dnsServer);
   }

 
   if(pSys) {
      pSys->Release();
   }
 
   CoUninitialize();
   return 0;
}

다음 Visual Basic 코드 예제에서는 Active Directory 도메인 컨트롤러 사이트의 이름을 검색합니다.

Dim sys As New ADSystemInfo
dc = sys.GetAnyDCName
Debug.Print "Domain Controller site: " & sys.GetDCSiteName(dc)

다음 VBScript/ASP 코드 예제에서는 Active Directory 도메인 컨트롤러 사이트의 이름을 검색합니다.

<%
Dim sys

Set sys = CreateObject("ADSystemInfo")

dc = sys.GetAnyDCName

wscript.echo "Domain Controller     : " & dc
wscript.echo "Domain Controller site: " & sys.GetDCSiteName(dc)

%>

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows Vista
지원되는 최소 서버 Windows Server 2008
대상 플랫폼 Windows
헤더 iads.h
DLL Activeds.dll

추가 정보

ADSI 오류 코드

Active Directory 핵심 개념

IADsADSystemInfo