|
Next: 10.1.6 Retrieving the commURI Up: 10.1 H.323 Previous: 10.1.4 Enabling Your Client
|
Once registration to the LDAP server succeeded, the endpoint needs to find the user's entry in the people's directory, and retrieve the commURI. Note that there may be more than one commURI associated with the user (for example, if the user is authorized to use an endpoint both in his/her own room and in a conference room.) In this case, it may be up to the user (or the application) to choose the right commURI. (step 8 on Diagram 1).
The value(s) of the commURI are LDAP URIs that point to the associated commObjects, such as, to a user's H.323 conferencing station and SIP IP phone. Note that multiple instances of commURI do not have point to the same commObject directory. In fact, each commURI instance could point to an endpoint managed by a different service provider.
The following example shows an LDAP entry for an user, containing a number of commURIs :
dn: uid=tsmith, ou=people, dc=vide,dc=net
commURI: ldap://dakar.oit.unc.edu/dc=vide,dc=net??sub?
(CommUniqueId=55) Tom's Laptop
commURI: ldap://dakar.oit.unc.edu/dc=vide,dc=net??sub?
(CommUniqueId=145) UNC-ATN Video Networking Conference Room
commURI: ldap://dakar.oit.unc.edu/dc=vide,dc=net??sub?
(CommUniqueId=195) Home ViaVideo
o: UNC Chapel Hill
givenName: Tom
street: CB #3455 G01 Morehead Labs
telephoneNumber: +1.919.843.7006
sn: Smith
l: Chapel Hill
ou: ATN
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: VIDECountry
objectClass: commURIObject
uid: timsmith
c: us
postalCode: 27599
cn: Tom Smith
title: Multimedia Telephony Analyst
st: NC
The following code sample shows how to find the commURI(s) from the user's entry:
char *attrs[2];
char DEFAULT_BASE[80] = "";
attrs[0] = "commuri";
attrs[1] = NULL;
/* Build the search base, using the user name */
sprintf(DEFAULT_BASE,"uid=%s,ou=people,dc=vide,dc=net",user);
/* Search for all the commuri entries under this user */
if (ldap_search_s(ld, DEFAULT_BASE,LDAP_SCOPE_BASE,
(objectclass=*),attrs, 0, &result) != LDAP_SUCCESS)
{
ldap_perror (ld, "ldap_search_s");
return (-1);
}
/* Go over the retrieved values */
/* Print the values found */
if ( (e = ldap_first_entry(ld, result)) != NULL)
{
if ( (vals = ldap_get_values( ld, e, "commuri" )) != NULL)
{
for ( i = 0; vals[i] != NULL; i++)
{
url = vals[i];
printf("%s\n", vals[i]);
/* The commuri will be parsed into the ludp structure
the fields of the structure will contain the host, the
dn where to look for the commObject entry, and the filter
with the specific value of the commObject - for example
CommUniqueId=56 in the example above */
if (( err = ldap_url_parse( url, &ludp )) != 0 )
{
printf( "ldap_url_parse: error %d\n", err );
}
else
{
printf( "\t host: " );
if ( ludp->lud_host == NULL )
{
printf( "DEFAULT\n" );
HOST = "localhost";
}
else
{
printf( "<%s>\n", ludp->lud_host );
HOST = ludp->lud_host;
}
printf( "\t port: " );
if ( ludp->lud_port == 0 )
{
printf( "DEFAULT\n" );
PORT = LDAP_PORT;
}
else
{
printf( "%d\n", ludp->lud_port );
PORT = ludp->lud_port;
}
SEARCHBASE = ludp->lud_dn;
printf("\t dn: <%s>\n", ludp->lud_dn );
printf("\t attrs:" );
if ( ludp->lud_attrs == NULL )
{
printf(" ALL" );
}
else
{
for ( i = 0; ludp->lud_attrs[ i ] != NULL; ++i )
{
printf( " <%s>", ludp->lud_attrs[ i ] );
}
}
printf( "\n\t scope: %s\n", ludp->lud_scope ==
LDAP_SCOPE_ONELEVEL ? "ONE" : ludp->lud_scope
== LDAP_SCOPE_BASE ? "BASE" : ludp->lud_scope
== LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
printf( "\tfilter: <%s>\n\n", ludp->lud_filter );
/* Let's now call the function that will follow the
LDAP URL and retrieve the */
/* information for this commUri */
url_ldap_search (ludp);
ldap_free_urldesc( ludp );
}
}
ldap_value_free (vals);
}
}
ldap_msgfree(result);
ldap_unbind(ld);