IADsADSystemInfo 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