2023年6月21日发(作者:)

java中search(),Java中的SearchResultI list users from LDAP with the following code:Hashtable env = new Hashtable();(L_CONTEXT_FACTORY, CONTEXT);(ER_URL, HOST);(TY_PRINCIPAL,USER);(TY_CREDENTIALS,PASSWORD);DirContext ctx = new InitialDirContext(env);SearchControls sc = new SearchControls();rchScope(E_SCOPE);NamingEnumeration items = (BASE, filter, sc);while (items != null && e()) {SearchResult sr = (SearchResult)();n("SR : " + sr) ;}Now I get an output of;SR : cn=smith: null:null:{objectclass=objectClass: person, sn=sn: smith, cn=cn: smith}SR : cn=king: null:null:{objectclass=objectClass: person, sn=sn: king, cn=cn: king}How can I get from SearchControls just the output like:sn = smith | cn = smithsn = king | cn = king解决⽅案Wouldn't a simple change in your sysout as below suffice?n("SR : "+ ributes().get("sn")+ " | "+ ributes().get("cn")) ;Or, am I reading something incorrectly here?

2023年6月21日发(作者:)

java中search(),Java中的SearchResultI list users from LDAP with the following code:Hashtable env = new Hashtable();(L_CONTEXT_FACTORY, CONTEXT);(ER_URL, HOST);(TY_PRINCIPAL,USER);(TY_CREDENTIALS,PASSWORD);DirContext ctx = new InitialDirContext(env);SearchControls sc = new SearchControls();rchScope(E_SCOPE);NamingEnumeration items = (BASE, filter, sc);while (items != null && e()) {SearchResult sr = (SearchResult)();n("SR : " + sr) ;}Now I get an output of;SR : cn=smith: null:null:{objectclass=objectClass: person, sn=sn: smith, cn=cn: smith}SR : cn=king: null:null:{objectclass=objectClass: person, sn=sn: king, cn=cn: king}How can I get from SearchControls just the output like:sn = smith | cn = smithsn = king | cn = king解决⽅案Wouldn't a simple change in your sysout as below suffice?n("SR : "+ ributes().get("sn")+ " | "+ ributes().get("cn")) ;Or, am I reading something incorrectly here?