/*
*
* Copyright 2000 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*
* Comments:
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include "lber.h"
#include "ldap.h"
#include "ldap-private.h"
#include "ldap-int.h"
#include "sec.h"
#include <strings.h>
BerElement * ldap_build_sasl_bind_req( LDAP *ld, char *dn, char *mechanism, struct berval *creds, LDAPControl ** serverctrls)
{
int err;
/* Create a Bind Request for SASL authentication.
* It look like this :
* BindRequest := [APPLICATION 0] SEQUENCE {
* version INTEGER,
* name LDAPDN,
* authentication CHOICE {
* sasl [3] SEQUENCE {
* mechanism LDAPString,
* credential OCTET STRING OPTIONAL
* }
* }
* }
* all wrapped up in an LDAPMessage sequence.
*/
return (NULLBER);
}
return (NULLBER);
}
if ( ber_printf( ber, "{it{ist{s", ++ld->ld_msgid, LDAP_REQ_BIND, ld->ld_version, dn, LDAP_AUTH_SASL, mechanism) == -1){
return (NULLBER);
}
return (NULLBER);
}
}
return( NULLBER );
}
/* LDAPv3 */
/* Code controls if any */
if (serverctrls && serverctrls[0]) {
return( NULLBER );
}
/* Otherwise, is there any global server ctrls ? */
return( NULLBER );
}
}
return( NULLBER );
}
return (ber);
}
/*
* ldap_sasl_bind - bind to the ldap server (and X.500).
* dn, mechanism, cred, serverctrls, and clientctrls are supplied.
* the message id of the request is returned in msgid
* Returns LDAP_SUCCESS or an error code.
*/
int ldap_sasl_bind(
char *dn,
char *mechanism,
int *msgidp)
{
int rv;
#ifdef _REENTRANT
#endif
/* Simple bind */
#ifdef _REENTRANT
#endif
return (theErr);
}
}
#ifdef _REENTRANT
#endif
return (theErr);
}
}
#ifdef _REENTRANT
#endif
return (theErr);
}
}
#ifdef _REENTRANT
#endif
return (LDAP_NOT_SUPPORTED);
/*
* if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
* ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
*#ifdef _REENTRANT
* UNLOCK_LDAP(ld);
*#endif
* return (theErr);
* }
*/
}
#ifdef _REENTRANT
#endif
return (LDAP_NOT_SUPPORTED);
/*
* if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
* ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
*#ifdef _REENTRANT
* UNLOCK_LDAP(ld);
*#endif
* return (theErr);
* }
*/
}
#ifdef _REENTRANT
#endif
return (LDAP_NOT_SUPPORTED);
/*
* if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
* ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
*#ifdef _REENTRANT
* UNLOCK_LDAP(ld);
*#endif
* return (theErr);
* }
*/
}
#ifdef _REENTRANT
#endif
return (LDAP_NOT_SUPPORTED);
/*
* if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
* ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
*#ifdef _REENTRANT
* UNLOCK_LDAP(ld);
*#endif
* return (theErr);
* }
*/
}
#ifdef _REENTRANT
#endif
return (LDAP_NOT_SUPPORTED);
/*
* if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
* ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
*#ifdef _REENTRANT
* UNLOCK_LDAP(ld);
*#endif
* return (theErr);
* }
*/
}
#ifdef _REENTRANT
#endif
return (LDAP_PARAM_ERROR);
}
#ifndef NO_CACHE
ldap_flush_cache( ld );
}
#endif /* !NO_CACHE */
/* send the message */
if (rv == -1){
if (rv == LDAP_SUCCESS){
rv = LDAP_OTHER;
}
#ifdef _REENTRANT
#endif
return (rv);
}
#ifdef _REENTRANT
#endif
return ( LDAP_SUCCESS );
}
/*
* ldap_sasl_bind_s - bind to the ldap server (and X.500).
* dn, mechanism, cred, serverctrls, and clientctrls are supplied.
* the message id of the request is returned in msgid
* Returns LDAP_SUCCESS or an error code.
*/
int ldap_sasl_bind_s(
char *dn,
char *mechanism,
struct berval **servercredp)
{
int msgid;
int retcode;
if ((retcode = ldap_sasl_bind(ld, dn, mechanism, cred, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
return (retcode);
}
char *dn,
{
int res;
char *theHDigest;
return (LDAP_PARAM_ERROR);
}
if ((res = ldap_sasl_bind_s(ld, dn, LDAP_SASL_CRAM_MD5, NULL, serverctrls, clientctrls, &challenge))
return (res);
}
return (LDAP_PARAM_ERROR);
}
if (theHDigest == NULL){
return (LDAP_NO_MEMORY);
}
return(LDAP_NO_MEMORY);
}
return (res);
}