2015-05-21 49 views

回答

1

有幾種方法可以從傳統的ASP中完成。

下面是Modifying an ADSI Object from ADO

'Replace department for all users in OU=sales. 
Set con = Server.CreateObject("ADODB.Connection") 
con.Provider = "ADsDSOObject" 

Set command = CreateObject("ADODB.Command") 
Set command.ActiveConnection = con 

command.CommandText = "SELECT AdsPath, cn FROM 'LDAP://OU=Sales,DC=Fabrikam,DC=com' WHERE objectClass = 'user'" 

command.Properties("searchscope") = ADS_SCOPE_ONELEVEL 
Set rs = command.Execute 
While Not rs.EOF 
    Set usr = GetObject(rs.Fields("AdsPath").Value) 
    usr.Put "department", "1001" 
    usr.SetInfo 
    rs.MoveNext 
Wend 

樣本下面是文章Getting Started with ASP for ADSI的樣本。

<%@ Language=VBScript %> 
<% 
' Get the inputs. 
containerName = Request.Form("inpContainer") 
' Validate compName before using. 

If Not ("" = containerName) Then 
    ' Bind to the object. 
    adsPath = "LDAP://" & containerName 
    Set comp = GetObject(adsPath) 

    ' Write the ADsPath of each of the child objects. 
    Response.Write("<p>Enumeration:</p>") 
    For Each obj in comp 
    Response.Write(obj.ADsPath + "<BR>") 
    Next 
End If 
%>