大网数据广告活动
域与目录服务

IADsADSystemInfo Property Methods (Iads.h)

· 52CE 我爱测

The property methods of the IADsADSystemInfo interface get or set the properties described in the following table. For more information, see Interface Property Methods.

The property methods of the IADsADSystemInfo interface get or set the properties described in the following table. For more information, see Interface Property Methods.

Properties

ComputerName

Retrieves the distinguished name of the local computer.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_ComputerName(
  [out] BSTR* pbstrComputer
);

DomainDNSName

Retrieves the DNS name of the local computer's domain, such as "domainName.companyName.com".

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_DomainDNSName(
  [out] BSTR* pbstr
);

DomainShortName

Retrieves the short name of the local computer's domain, such as "domainName".

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_DomainShortName(
  [out] BSTR* pbstrDSN
);

ForestDNSName

Retrieves the DNS name of the local computer's forest.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_ForestDNSName(
  [out] BSTR* pbstr
);

IsNativeMode

Determines whether the local computer's domain is in native or mixed mode.

Access type: Read-only

Scripting data type: BOOL

// C++ method syntax
HRESULT get_IsNativeMode(
  [out] BOOL* pvBool
);

PDCRoleOwner

Retrieves the distinguished name of the directory service agent (DSA) object for the DC that owns the primary domain controller role in the local computer's domain.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_PDCRoleOwner(
  [out] BSTR* pbstr
);

SchemaRoleOwner

Retrieves the distinguished name of the directory service agent (DSA) object for the DC that owns the schema master role in the local computer's forest.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_SchemaRoleOwner(
  [out] BSTR* pbstr
);

SiteName

Retrieves the site name of the local computer.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_SiteName(
  [out] BSTR* pbstrSite
);

UserName

Retrieves the Active Directory distinguished name of the current user, which is the logged-on user or the user impersonated by the calling thread.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_UserName(
  [out] BSTR* pbstrUser
);

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->get_UserName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("User: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   hr = pSys->get_ComputerName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("Computer: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   hr = pSys->get_DomainDNSName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("Domain: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   hr = pSys->get_PDCRoleOwner(&bstr);
   if (SUCCEEDED(hr)) {
      printf("PDC Role owner: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   if(pSys) {
      pSys->Release();
   }
 
   CoUninitialize();
   return 0;
}

The following Visual Basic code example retrieves the Windows system information.

Dim sys As New ADSystemInfo
Debug.print "User: " & sys.UserName
Debug.print "Computer: " & sys.ComputerName
Debug.print "Domain: " & sys.DomainDNSName
Debug.print "PDC Role Owner: " & sys.PDCRoleOwner

The following VBScript/ASP code example retrieves the Windows system information.

<%
Dim sys
Set sys = CreateObject("ADSystemInfo")
Response.Write "User: " & sys.UserName
Response.Write "Computer: " & sys.ComputerName
Response.Write "Domain: " & sys.DomainDNSName
Response.Write "PDC Role Owner: " & sys.PDCRoleOwner
%>

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Header Iads.h
DLL Activeds.dll
IID IID_IADsADSystemInfo is defined as 5BB11929-AFD1-11D2-9CB9-0000F87A369E

See also

IADsADSystemInfo

CoCreateInstance

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。