ldap_set_option for LDAP_OPT_REFERRALS return LDAP_PARAM_ERROR on windows 2000
- From: hagaiy@xxxxxxxxx
- Date: 10 Dec 2006 08:56:09 -0800
Hello,
I have a problem using Microsoft LDAP API, I have attached an example
program that works fine on windows 2003 but fails on windows 2000
server SP4.
The program fails (with code 0x59 - LDAP_PARAM_ERROR) in the
ldap_set_option call when i am trying to set the LDAP_OPT_REFERRALS to
LDAP_OPT_OFF, the example program is:
#include <stdio.h>
#include <windows.h>
#include <winldap.h>
int main(int argc, char** argv)
{
LDAP* ld = NULL;
INT iRtn = 0;
INT connectSuccess = 0;
PCHAR pHost = NULL;
ULONG version = LDAP_VERSION3;
ULONG uOpt;
//SecPkgContext_ConnectionInfo sslInfo;
LONG lv = 0;
// Verify that the user passed a hostname.
if (argc > 1)
{
pHost = argv[1];
printf("\nConnecting to host \"%s\" ...\n",pHost);
}
// If not, perform a 'serverless' bind.
else
{
pHost = NULL;
printf("\nConnecting to DEFAULT LDAP host ...\n");
}
// Create an LDAP session.
ld = ldap_sslinit(pHost,LDAP_PORT,0);
if (ld == NULL)
{
printf( "ldap_sslinit failed with 0x%x.\n",GetLastError());
return -1;
}
// Specify version 3; the default is version 2.
printf("Setting Protocol version to 3.\n");
iRtn = ldap_set_option(ld,
LDAP_OPT_PROTOCOL_VERSION,
(void*)&version);
if (iRtn != LDAP_SUCCESS)
goto FatalExit;
// Specify version 3; the default is version 2.
printf("Setting Ref\n");
//uOpt = LDAP_OPT_OFF
iRtn = ldap_set_option(ld,
LDAP_OPT_REFERRALS,
LDAP_OPT_OFF);
if (iRtn != LDAP_SUCCESS)
goto FatalExit;
// Bind with current credentials.
printf("Binding ...\n");
iRtn =
ldap_bind_s(ld,"cn=administrator,cn=users,dc=infradc,dc=com","Local",LDAP_AUTH_SIMPLE);
if (iRtn != LDAP_SUCCESS)
goto FatalExit;
goto NormalExit;
// Cleanup.
NormalExit:
if (ld != NULL)
ldap_unbind_s(ld);
return 0;
// Cleanup after an error.
FatalExit:
if( ld != NULL )
ldap_unbind_s(ld);
printf( "\n\nERROR: 0x%x\n", iRtn);
return iRtn;
}
If instead of using the LDAP_OPT_OFF as parameter to the function
(which is correct according to the documentation) I will set a local
variable (uOpt) to that value and use it as input to the function it
will work on windows 2000 & windows 2003.
Is this a bug in windows API / Documentation? Or maybe I am doing
something wrong?
What is the recommended way to do this?
Thanks,
Hagai.
.
- Prev by Date: Re: Security Groups for Users Not Updating
- Next by Date: Re: tombstone life and R2
- Previous by thread: Re: Security Groups for Users Not Updating
- Next by thread: Re: Group Policy
- Index(es):
Relevant Pages
|