我的ASP站点有LDAP身份验证。代码在Windows 2003 Server上正常运行。但是,我们需要将我们的应用程序迁移到Windows 2012 R2服务器。遗憾的是,同样不起作用错误来自"服务器无法运行。"
以下是我的代码。请建议同样的
Function AuthUser(strFSUID, strPwd)
Const ADS_FAST_BIND_SSL = 34 'forces fast binding and SSL connection
Const strADSPath =
"LDAP://mdsoti.fsu.edu:636/ou=People,dc=fsu,dc=edu" 'full path to LDAP server
Const strProxyUser = "proxy-user" 'proxy username For establishing initial connection to LDAP
Const strProxyPass = "proxy-pass" 'proxy password For establishing initial connection To LDAP
Dim conADODB 'LDAP admin connection
Dim comADODB 'User DB connection
Dim rsLDAP 'recordset to hold user information
Dim dsoLDAP 'LDAP system object
Dim conUser 'LDAP connection to validate username and password
Dim strPath 'users FQDN path
Dim strUser 'users dn stripped from ADsPath
Dim blnAuthenticated 'has user been authenticated: 0 = no, -1 = yes
On Error Resume Next
blnAuthenticated = False
'Create our admin connection for retrieving user DN
Set conADODB = CreateObject("ADODB.Connection")
conADODB.Provider = "ADsDSOObject"
conADODB.Properties("user ID") = "cn=" & strProxyUser & ",ou=proxy-users,dc=fsu,dc=edu"
conADODB.Properties("Password") = strProxyPass
conADODB.Properties("ADSI Flag") = ADS_FAST_BIND_SSL
conADODB.Open "ADSI"
'next we get the users dn
Set comADODB = CreateObject("ADODB.Command")
Set comADODB.ActiveConnection = conADODB
comADODB.CommandText = "<" & strADSPath & ">;(cn=" & strFSUID & ");Adspath,cn,;subtree"
Set rsLDAP = comADODB.Execute
'finally, we validate the actual username and password
While Not (rsLDAP.EOF)
strPath = rsLDAP.fields("ADsPath")
wscript.echo strPath
'strip out user dn from ADsPath
strUser = InStrRev(strPath, "/")
strUser = Mid(strPath, strUser + 1)
wscript.echo strUser
'open connection to authenticate users FSUID and password
Set dsoLDAP = GetObject("LDAP:")
Set conUser = dsoLDAP.OpenDSObject(strADSPath, strUser, strPwd, ADS_FAST_BIND_SSL)
'see if the user's password worked. if not print error message
If Err.Number <> 0 Then
blnAuthenticated = False
Else
blnAuthenticated = True
End If
v = rsLDAP.fields("cn")
wscript.echo v(0)
rsLDAP.MoveNext
Wend
AuthUser = blnAuthenticated
End Function
执行&#34;设置rsLDAP = comADODB.Execute&#34;
时出错谢谢你