|
Next: 10.2.8 Fetch SIPIdentitySIPURI in Up: 10.2 SIP Previous: 10.2.6 Binding with a
|
The following code shows how to accumulate commURIs from an LDAP server
for a User DN provided by a user. This is executed in Step 6 of Figure
.
public static String collectCommURIs(String vName,
DirContext vDirCtx, String bDN )
{
String strCommURIs = new String("");
try
{
String fltrEnterprise = "(&("+vName+") )";
SearchControls ctlEnterprise = new SearchControls();
ctlEnterprise.setSearchScope(SearchControls.SUBTREE_SCOPE);
/* Set the returning attributes to commURI and CN */
String[] entAttrs = {"commURI","cn"};
ctlEnterprise.setReturningAttributes(entAttrs);
String s1[] = ctlEnterprise.getReturningAttributes();
/* Fetch the results containing commURI and CN specified
in filter based on DN */
NamingEnumeration commURIResult = vDirCtx.search(
bDN,fltrEnterprise,ctlEnterprise);
/* Iterate the results to count the number of commURIs
and form a string that has commURIs for a UserDN */
while(commURIResult.hasMore())
{
SearchResult srchCommRslt = (SearchResult)
commURIResult.next();
Attributes allAttrs = srchCommRslt.getAttributes();
Attribute commURI = allAttrs.get("commURI");
cntCommURIs = commURI.size();
strCommURIs = commURI.toString();
}
}
catch (NamingException e)
{
System.err.println("Error in collectCommURIs - " +
e.getMessage());
}
return strCommURIs;
}