Directory Services |
The property methods of the IADsADSystemInfo interface get or set the properties described in the following table. For more information, see Interface Property Methods.
Property | Description |
---|---|
UserName
[Visual Basic] [C++] |
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] [C++] |
Retrieves the distinguished name of the local computer. |
SiteName
[Visual Basic] [C++] |
Retrieves the site name of the local computer. |
DomainShortName
[Visual Basic] [C++] |
Retrieves the short name of the local computer's domain, such as "domainName". |
DomainDNSName
[Visual Basic] [C++] |
Retrieves the DNS name of the local computer's domain, such as "domainName.companyName.com". |
ForestDNSName
[Visual Basic] [C++] |
Retrieves the DNS name of the local computer's forest. |
PDCRoleOwner
[Visual Basic] [C++] |
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] [C++] |
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] [C++] |
Determines whether the local computer's domain is in native or mixed mode. |
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; }
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
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 %>
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Header: Declared in Iads.h.
IADsADSystemInfo, CoCreateInstance