View Javadoc
1 package jsdsi.ldap; 2 3 import com.novell.ldap.*; 4 5 /*** 6 * LDAP composed operations used by jsdsi.ldap.LDAPOperations 7 * 8 * @see jsdsi.ldap.LDAPOperations 9 * 10 * @author Lu�s Pedro 11 * @version $Revison: 1.3 $Date: 21/Mar/2004 15:11:05 12 * 13 **/ 14 15 class LDAPOp extends LDAPAttributes { 16 /*** 17 * LDAP Schema 18 */ 19 private LDAPSchema dirSchema; 20 21 /*** 22 * LDAP Connection 23 */ 24 private LDAPConnection lc; 25 26 /*** 27 * LDAP Parameters 28 */ 29 private LDAPParameters params; 30 31 /*** 32 * Create a new instance of LDAPOp 33 * 34 * @param params ldap parameters 35 */ 36 LDAPOp(LDAPParameters params) { 37 lc = new LDAPConnection(); 38 this.params = params; 39 } 40 41 /*** 42 * Ldap connection 43 * 44 * @throws LDAPException 45 */ 46 void LDAPConnection() throws LDAPException { 47 lc.connect(params.getLDAPserver(), params.getLDAPport()); 48 } 49 50 /*** 51 * Ldap connection using user name and password 52 * 53 * @throws LDAPException 54 */ 55 void LDAPBindConnection() throws LDAPException { 56 lc.connect(params.getLDAPserver(), params.getLDAPport()); 57 lc.bind(LDAPConnection.LDAP_V3, 58 params.getLDAPlogin(), (params.getLDAPpassword()).getBytes()); 59 } 60 61 /*** 62 * Ldap disconnection 63 * 64 * @throws LDAPException 65 */ 66 void LDAPDisconnection() throws LDAPException { 67 lc.disconnect(); 68 } 69 70 /*** 71 * Ldap delete 72 * 73 * @param composedAttribute composed attribute to delete 74 * @throws LDAPException 75 */ 76 void LDAPDelete(String composedAttribute) throws LDAPException{ 77 lc.delete(composedAttribute + params.getLDAPbaseDN()); 78 } 79 80 /*** 81 * Adds elements to the ldap server 82 * 83 * @param composedAttribute composed attribute that identifies the element 84 * @param attributeSet set of attributes to store 85 * @throws LDAPException 86 */ 87 void LDAPStore(String composedAttribute, 88 LDAPAttributeSet attributeSet) throws LDAPException { 89 LDAPEntry newEntry = new LDAPEntry(composedAttribute + params.getLDAPbaseDN(), attributeSet); 90 lc.add(newEntry); 91 } 92 93 /*** 94 * Make ldap searchs with a specified ldap schema composed attribute 95 * 96 * @param filter ldap search filter 97 * @param composedAttribute ldap schema composed attribute 98 * @param searchScope search scope - BASE, SUB, ONE 99 * @param attributes attribute values to return 100 * @return result of search operation over the ldap server 101 * @throws LDAPException 102 */ 103 LDAPSearchResults LDAPSearch(String filter, 104 String composedAttribute, 105 int searchScope, 106 String[] attributes) throws LDAPException { 107 LDAPSearchResults searchResults = null; 108 dirSchema = lc.fetchSchema(lc.getSchemaDN()); 109 if(composedAttribute != null) { 110 searchResults = lc.search(composedAttribute + params.getLDAPbaseDN(), 111 searchScope, filter, 112 attributes, false); 113 } else 114 searchResults = lc.search(params.getLDAPbaseDN(), 115 searchScope, filter, attributes, false); 116 117 return searchResults; 118 } 119 120 /*** 121 * Make generic ldap searchs 122 * 123 * @param filter ldap search filter 124 * @param searchScope search scope - BASE, SUB, ONE 125 * @param attributes attribute values to return 126 * @return result of search operation over the ldap server 127 * @throws LDAPException 128 */ 129 LDAPSearchResults LDAPSearch(String filter, 130 int searchScope, 131 String[] attributes) throws LDAPException { 132 return LDAPSearch(filter, null, searchScope, attributes); 133 } 134 135 /*** 136 * Ldap parameters used to perform operations 137 * 138 * @return ldap parameters 139 */ 140 public LDAPParameters getParameters() { 141 return params; 142 } 143 }

This page was automatically generated by Maven