[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: SOCKET handling and Netscape SDK bug(?)



[ this is a follow up on a Netscape - openLDAP root DSE question, be
response/question below contain some code which lenghtens the mail...I
appologize for this]

"Kurt D. Zeilenga" wrote:

> At 12:13 PM 7/25/00 +0200, Mikael Grehn wrote:
> >2.
> >    I added the propriate root DSE attributes to "root_dse_info(...)"

> >function and when debugging(VC6) everything looks great.
> >    I then tried to get the rootDSE entry using Netscape SDK 4.0
client
> >package (the example in chapter 11, page 3 of NSSDK3.0 manual) BUT it

> >only received the last attributetype from the entry ("objectclass"
> >values). The received entry didnt not contain the "namingContext"
> >attribute or the schema attribute.
>
> Did the client request that the operational attributes be returned
> with the results?

Ehum....yes, I have used exactly the same code when getting root DSE
from
other servers (elvira.innosoft.com, etc) and I get a complete listing of
all
available attributes (and all their value). Lets me include the basic
code
in from client:

//--------------------------------------------------------------------------

   LDAP *ld;
   LDAPMessage *result,*e;
   BerElement *ber;
   int version;
   char *a;
   char **vals;
   int i,rc;
   ld=ldap_init(HOSTNAME,PORT_NUMBER);
   version=LDAP_VERSION3;
   ldap_set_option(ld,LDAP_OPT_PROTOCOL_VERSION,&version);
   ldap_set_option(ld,LDAP_OPT_REFERRALS,LDAP_OPT_OFF);
   rc=ldap_search_ext_s(ld,"",LDAP_SCOPE_BASE,"(objectclass=*)",NULL,0,
NULL,NULL,NULL,0,&result);
   switch(rc)
   {
        [...snip...]
        case LDAP_SUCCESS:
        {
             e=ldap_first_entry(ld,result);
             if (e!=NULL)
             {
                   for
(a=ldap_first_attribute(ld,e,&ber);a!=NULL;a=ldap_next_attribute(ld,e,ber))

                  {
                       if ((vals=ldap_get_values(ld,e,a))!=NULL)
                       {
                            for (i=0;vals[i]!=NULL;i++)
                            {
                                 printf("%s: %s\n",a,vals[i]);
                            }
                            ldap_value_free(vals);
                       }
                       ldap_memfree(a);
                  }
                  if (ber!=NULL)
                  {
                       ber_free(ber,0);
                  }
             }
             ldap_msgfree(result);
             printf("Finished presenting root DSE\n");
             ldap_unbind(ld);
             return (0);
        } // case LDAP_SUCCESS
//----------------------------------------------------------------------------------

This is ofcourse based on Netscape SDK 4.0 and the example is directly
taken
from the NS SDK3.0 manual (shortened here ofcourse). The rootDSE
function in
openLDAP (openLDAP2.0-alpha3 on NT) is:

//----------------------------------------------------------------------------------

void root_dse_info( Connection *conn, Operation *op, char **attrs, int
attrsonly )
{
     char buf[BUFSIZ];
     Entry  *e;
     struct berval val;
     struct berval *vals[2];
     int  i, j;
     vals[0] = &val;
     vals[1] = NULL;
     e = (Entry *) ch_calloc( 1, sizeof(Entry) );
     e->e_attrs = NULL;
     e->e_dn = ch_strdup( LDAP_ROOT_DSE );
     e->e_ndn = ch_strdup( LDAP_ROOT_DSE );
     (void) dn_normalize_case( e->e_ndn );
     e->e_private = NULL;

 for ( i = 0; i < nbackends; i++ )
 {
      for ( j = 0; backends[i].be_suffix[j] != NULL; j++ )
     {
           val.bv_val = backends[i].be_suffix[j];
           val.bv_len = strlen( val.bv_val );
           attr_merge( e, "namingContexts", vals );
      }
 }
#if defined( SLAPD_MONITOR_DN )
 val.bv_val = SLAPD_MONITOR_DN;
 val.bv_len = strlen( val.bv_val );
 attr_merge( e, "namingContexts", vals );
 /* subschemasubentry is added by send_search_entry() */
#endif

#if defined( SLAPD_CONFIG_DN )
 val.bv_val = SLAPD_CONFIG_DN;
 val.bv_len = strlen( val.bv_val );
 attr_merge( e, "namingContexts", vals );
#endif

#if defined( SLAPD_SCHEMA_DN )
 val.bv_val = SLAPD_SCHEMA_DN;
 val.bv_len = strlen( val.bv_val );
 attr_merge( e, "namingContexts", vals );
#endif

 /* altServer unsupported */

 /* supportedControl */
 for ( i=0; supportedControls[i] != NULL; i++ )
 {
  val.bv_val = supportedControls[i];
  val.bv_len = strlen( val.bv_val );
  attr_merge( e, "supportedControl", vals );
 }

 /* supportedExtension */
 for ( i=0; supportedExtensions[i] != NULL; i++ )
 {
  val.bv_val = supportedExtensions[i];
  val.bv_len = strlen( val.bv_val );
  attr_merge( e, "supportedExtension", vals );
 }

 /* supportedLDAPVersion */
 for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ )
 {
  sprintf(buf,"%d",i);
  val.bv_val = buf;
  val.bv_len = strlen( val.bv_val );
  attr_merge( e, "supportedLDAPVersion", vals );
 }

 /* supportedSASLMechanism */
 if( supportedSASLMechanisms != NULL )
 {
  for ( i=0; supportedSASLMechanisms[i] != NULL; i++ )
  {
   val.bv_val = supportedSASLMechanisms[i];
   val.bv_len = strlen( val.bv_val );
   attr_merge( e, "supportedSASLMechanisms", vals );
  }
 }

 if ( default_referral != NULL )
 {
  attr_merge( e, "ref", default_referral );
 }

 val.bv_val = "top";
 val.bv_len = sizeof("top")-1;
 attr_merge( e, "objectClass", vals );

 val.bv_val = "LDAPsubentry";
 val.bv_len = sizeof("LDAPsubentry")-1;
 attr_merge( e, "objectClass", vals );

 val.bv_val = "extensibleObject";
 val.bv_len = sizeof("extensibleObject")-1;
 attr_merge( e, "objectClass", vals );

 send_search_entry( &backends[0], conn, op,
  e, attrs, attrsonly, NULL );
 send_search_result( conn, op, LDAP_SUCCESS,
  NULL, NULL, NULL, NULL, 1 );

 entry_free( e );
}
//------------------------------------------------------------------------------------------

I appologize for all this code but it seem to be the best way to solve
the
problem.

I debugged both programs and the entry sent away do contain all
attributes
(and values) but they "dissappear" when the result is collected in the
LDAPMessage on client side.

Perhaps someone using (or writing) Netscape SDK have a clue?

Thanks for your help!

--
mvh/sincerely

Mikael Grehn
M.Sc
Systems Engineer
Envilogg Datateknik AB
Tel: +46 (0)18 ? 135918
Fax: +46 (0)18 ? 125968
Email: mikael@envilogg.se