ISAPI filter with LDAP over SSL only works as administrator
Posted
by
Zac
on Server Fault
See other posts from Server Fault
or by Zac
Published on 2012-06-22T22:33:11Z
Indexed on
2012/06/23
3:18 UTC
Read the original article
Hit count: 584
I have created an ISAPI filter for IIS 6.0 that tries to authenticate against Active directory using LDAP. The filter works fine when authenticating regularly over port 389, but when I try to use SSL, I always get the 0x51 Server Down
error at the ldap_connect()
call. Even skipping the connect call and using ldap_simple_bind_s()
results in the same error.
The weird thing is that if I change the app pool identity to the local admin account, then the filter works fine and LDAP over SSL is successful. I created an exe with the same code below and ran it on the server as admin and it works. Using the default NETWORK SERVICE identity for the site's app pool is what seems to be the problem. Any thoughts as to what is happening? I want to use the default identity since I don't want the website to have elevated admin privileges.
The server is in a DMZ outside the network and domain where our DCs are that run AD. We have a valid certificate on our DCs for AD as well.
Code:
// Initialize LDAP connection
LDAP * ldap = ldap_sslinit(servers, LDAP_SSL_PORT, 1);
ULONG version = LDAP_VERSION3;
if (ldap == NULL)
{
strcpy(error_msg, ldap_err2string(LdapGetLastError()));
valid_user = false;
}
else
{
// Set LDAP options
ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, (void *) &version);
ldap_set_option(ldap, LDAP_OPT_SSL, LDAP_OPT_ON);
// Make the connection
ldap_response = ldap_connect(ldap, NULL); // <-- Error occurs here!
// Bind and continue...
}
UPDATE: I created a new user without admin privileges and ran the test exe as the new user and I got the same Server Down
error. I added the user to the Administrators group and got the same error as well. The only user that seems to work with LDAP over SSL authentication on this particular server is administrator.
The web server with the ISAPI filter (and where I've been running the test exe) is running Windows Server 2003. The DCs with AD on them are running 2008 R2.
Also worth mentioning, we have a WordPress site on the same server that authenticates against LDAP over SSL using PHP (OpenLDAP) and there's no problem there. I have an ldap.conf file that specifies TLS_REQCERT never
and the user running the PHP code is IUSR.
© Server Fault or respective owner