Directory Services

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

Property Description
UserName

[Visual Basic]
Access: Read-only
DataType: BSTR

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

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

[Visual Basic]
Access: Read-only
DataType: BSTR

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

Retrieves the distinguished name of the local computer.
SiteName

[Visual Basic]
Access: Read-only
DataType: BSTR

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

Retrieves the site name of the local computer.
DomainShortName

[Visual Basic]
Access: Read-only
DataType: BSTR

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

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

[Visual Basic]
Access: Read-only
DataType: BSTR

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

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

[Visual Basic]
Access: Read-only
DataType: BSTR

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

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

[Visual Basic]
Access: Read-only
DataType: BSTR

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

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.
SchemaRoleOwner

[Visual Basic]
Access: Read-only
DataType: BSTR

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

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.
IsNativeMode

[Visual Basic]
Access: Read-only
DataType: Variant Boolean

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

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

Example Code [C++]

The following C++ code example retrieves the Windows 2000 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;
}

Example Code [Visual Basic]

The following Visual Basic code example retrieves the Windows 2000 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

Example Code [VBScript]

The following VBScript/ASP code example retrieves the Windows 2000 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

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Header: Declared in Iads.h.

See Also

IADsADSystemInfo, CoCreateInstance