ldap question

Hi All,

I’m trying to login (programmatically) to an Active directory server.
The program I am testing is already in that domain, and I logged in with
my usid/psw. Now I want to the progam to login as another usr/psw.

int main( int argc, char** argv )
{
LDAP* psLdap = ldap_init( “engsrvr.mydomain.com”, LDAP_PORT );

if( psLdap != NULL )
{
ULONG uErr = LDAP_SUCCESS;

const PCHAR pszUserName = “CN=DaveS,CN=Users,DC=megacorp,DC=com”;
const PCHAR pszDomainName = “MEGACORP”;
const PCHAR pszPassword = “johns”; //“secret-mcgw”;

SEC_WINNT_AUTH_IDENTITY sIdentity;

sIdentity.User = ( unsigned char* )pszUserName;
sIdentity.UserLength = strlen( pszUserName );
sIdentity.Domain = ( unsigned char* )pszDomainName;
sIdentity.DomainLength = strlen( pszDomainName );
sIdentity.Password = ( unsigned char* )pszPassword;
sIdentity.PasswordLength = strlen( pszPassword );
sIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;

uErr = ldap_bind_s(
psLdap,
pszUserName,
( const PCHAR )&sIdentity,
LDAP_AUTH_NEGOTIATE
//LDAP_AUTH_SSPI
);

if( uErr == LDAP_SUCCESS )
{
cout << “Bind succeeded” << endl;
}else
ProcessErr(uErr);

ldap_unbind( psLdap );
}

return 0;
}

What I’m getting is that Server can not update the passwd, the passwd is
incorrect.

Since I do have admin on this server, I create some usr with or w/o psw,
tried both, and get the same answer…

Any thought or help !!!

TIA
-prokash