Red Hat NETSCAPE ENTERPRISE SERVER 6.0 - NSAPI PROGRAMMER GUIDE User's Guide Page 306

  • Download
  • Add to my manuals
  • Print
  • Page
    / 332
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 305
Appendix A: Samples of User Program Descriptions
A-8
Adding a User Role
This sample program assumes the environment setup below. Change the setup according to the actual
environment used.
The public directory for creation of the repository is "ou=interstage,o=fujitsu,dc=com".
The storage location of user information is "ou=User,ou=interstage,o=fujitsu,dc=com".
RDN of user information is expressed by "cn".
The name of the user whose role is to be added is specified for "user" in java.lang.String.
The role to be added is specified for "role" in java.lang.String.
The result of common pre-processing is used as the value of "ctx".
Description of User Program
Example
Pre-processing
:
String [] retAttributes = new String[1];
retAttributes[0] = "ssoRoleName";
SearchControls sc = new SearchControls();
sc.setSearchScope(SearchControls.OBJECT_SCOPE);
sc.setReturningAttributes(retAttributes);
sc.setCountLimit(1);
sc.setTimeLimit(5*1000); // 5 seconds
String filter = "(cn=" + user + ")";
String dn = "cn=" + user + ",ou=User,ou=interstage,o=fujitsu,dc=com";
NamingEnumeration ne = ctx.search(dn, filter, sc);
Attribute roleAttr = null;
while(ne.hasMore()) {
SearchResult sr = (SearchResult)ne.next();
Attributes attrs = sr.getAttributes();
if(attrs != null) {
roleAttr = attrs.get("ssoRoleName");
if(roleAttr != null) {
break;
}
}
}
if(roleAttr == null) {
roleAttr = new BasicAttribute("ssoRoleName", role);
} else {
// No processing if the role already exists
Page view 305
1 2 ... 301 302 303 304 305 306 307 308 309 310 311 ... 331 332

Comments to this Manuals

No comments