使用LDAP缓慢ASP Classic身份验证

时间:2013-07-03 06:46:15

标签: asp-classic ldap ado

我使用asp classic来验证LDAP用户。 LDAP中有大约10 000个帐户,并且在asp中检查身份验证的速度非常慢(15秒)。

我在同一台服务器上使用了LDP工具(from Microsoft),所有东西(来自连接,绑定和搜索)都很快。

这是我的代码,我尝试了3个不同的选项,我得到了相同的结果:

使用SQL指令:

Dim oConn: Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOOBJECT"
oConn.Properties("User ID") = Username
oConn.Properties("Password") = Password
oConn.Properties("Encrypt Password") = True
oConn.Open "DS Query", Username, Password
Dim Query: Query = "SELECT sAMAccountName FROM 'LDAP://ldap.mydomain.com/CN=" & Username & ",CN=Users' WHERE objectCategory = 'person' AND objectClass='user' AND SAMAccountName = '" & Username & "' "
Dim oCmd: Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oConn
oCmd.CommandText = Query
Dim oRs: Set oRS = oCmd.Execute
If oRS.BOF Or oRS.EOF Then
    ' Authentication failed
Else
    ' Autentication passed
End If
...

使用LDAP说明:

Dim oConn: Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOOBJECT"
oConn.Properties("User ID") = Username
oConn.Properties("Password") = Password
oConn.Properties("Encrypt Password") = True
oConn.Open "DS Query", Username, Password
Dim Query: Query = "<LDAP://ldap.mydomain.com>;(samAccountName=" & Username & ");samAccountName;subtree"
Dim oCmd: Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oConn
oCmd.CommandText = Query
Dim oRs: Set oRS = oCmd.Execute
If oRS.BOF Or oRS.EOF Then
    ' Authentication failed
Else
    ' Autentication passed
End If
...

使用IADS对象:

Dim DSODomaine
Dim DSOContainer

On Error Resume Next

Set DSODomaine = GetObject("LDAP:")
Set DSOContainer = DSODomaine.OpenDSObject("LDAP://ldap.mydomain.com", Username, Password, ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)

If Err.Number <> 0 Then
    ' Authentication failed
Else
    ' Autentication passed
End If
...

这三个例子都很慢。我该怎么做才能使用asp classic提高性能?

0 个答案:

没有答案
相关问题