Red Hat NETSCAPE ENTERPRISE SERVER 6.0 - NSAPI PROGRAMMER GUIDE Guía de usuario Pagina 310

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 332
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 309
Appendix A: Samples of User Program Descriptions
A-12
Displaying the User Lock Status
This sample program assumes the environment setup below. Change the setup according to the actual
environment used.
The public directory at 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 lock status is to be displayed is specified for "user" in java.lang.String.
The result of common preprocessing is used as the value of "ctx".
Description of User Program
Example
Pre-processing
:
String [] retAttributes = new String [1];
retAttributes[0] = "ssoUserStatus";
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);
while(ne.hasMore()) {
SearchResult sr = (SearchResult)ne.next();
Attributes attrs = sr.getAttributes();
if(attrs != null) {
Attribute a = attrs.get("ssoUserStatus");
if(a == null) {
System.out.println("Not locked");
return;
} else {
String value = (String)a.get();
if(value.compareToIgnoreCase("locked") == 0) {
System.out.println("Locked");
return;
} else {
System.out.println("Not locked");
return;
}
Vista de pagina 309
1 2 ... 305 306 307 308 309 310 311 312 313 314 315 ... 331 332

Comentarios a estos manuales

Sin comentarios