-#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
- if ( cdn != NULL ) {
- free( cdn );
- }
- if ( ndn != NULL ) {
- free( ndn );
- }
- if ( cred.bv_val != NULL ) {
- free( cred.bv_val );
+ ndn = ch_strdup( dn );
+
+ if ( dn_normalize_case( ndn ) == NULL ) {
+ Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n", dn, 0, 0 );
+ send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
+ "invalid DN", NULL, NULL );
+ goto cleanup;
+ }
+
+ op->o_protocol = version;
+
+ if( method != LDAP_AUTH_SASL ) {
+ tag = ber_scanf( ber, /*{*/ "o}", &cred );
+
+ } else {
+ tag = ber_scanf( ber, "{a" /*}*/, &mech );
+
+ if ( tag != LBER_ERROR ) {
+ ber_len_t len;
+ tag = ber_peek_tag( ber, &len );
+
+ if ( tag == LDAP_TAG_LDAPCRED ) {
+ tag = ber_scanf( ber, "o", &cred );
+ }
+
+ if ( tag != LBER_ERROR ) {
+ tag = ber_scanf( ber, /*{{*/ "}}" );
+ }