Development, Analysis And Research


PHP5 & ADSI (Active Directory Service Interfaces)

Posted in PHP by Andrew Johnstone on the March 14th, 2005

Extending on Wez Furlongs article at zend on Com… Firstly lets clear up a little introduction to ADSI and its relevance to Com.

Active Directory Service Interfaces (ADSI) abstracts the capabilities of directory services from different network providers in a distributed computing environment, to present a single set of directory service interfaces for managing network resources. Administrators and developers can use ADSI services to enumerate and manage the resources in a directory service, no matter which network environment contains the resource.

The following figure shows how ADSI fits into an application environment. Whether the application is written in Visual Basic, C/C++, VBScript, Microsoft JScript, or as a Web application using Active Server Pages, Active Directory Service Interfaces provide a clean and easy-to-use access to the underlying directory services without having to use the native network APIs.
ADSI (Active Directory Service Interfaces) Model

Thats nice, but what can ADSI do?

ADSI exposes interfaces to automate common administrative tasks, such as adding users and groups, managing printers, and setting permissions on network resources. Administrators use Windows Management Instrumentation (WMI) to manage operating systems via Windows Management Instrumentation Query Language (WQL). WMI is a component of the Windows OS that is an industry initiative to develop a standard technology for accessing management information in an enterprise environment, which uses the Common Information Model (CIM) provider that represent systems, applications, networks, devices, and other managed components. Confused?

Through the use of these providers,..

  • winmgmts://
  • cim://
  • LDAP://
  • WinNT://
  • NDS://
  • NWCOMPAT://
  • More Providers

Some simple examples…

  strComputer = "."
  Set objWMIService = GetObject("winmgmts:" & strComputer & "root//cimv2")
  Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service where Name Like '%ADAM_%'")
  If colServices.Count = 0 Then
    Wscript.Echo "ADAM is not installed."
  Else
    For Each objService in colServices
      Wscript.Echo objService.Name & " -- " & objService.State
    Next
  End If


Domain:


$domainObject = new COM("WinNT://Domain/"); //If the Domain is the local server, a period signifies this…
foreach ($domainObject as $obj) {
  echo $obj->Name;
}

Leave a Reply