Raju created DIRSTUDIO-1237: ------------------------------- Summary: How to Edit an Entry in through code Key: DIRSTUDIO-1237 URL: https://issues.apache.org/jira/browse/DIRSTUDIO-1237 Project: Directory Studio Issue Type: Brainstorming Components: studio-ldapbrowser Affects Versions: 2.0.0-M14 Environment: Windows10-64Bit, Reporter: Raju
Hi Team, I am working new editor plug-in, where I need to edit Entry which is an object class groupOfUniqueNames. I able to fetch the entry object, but somehow add method is not saving the values. here is my use case step by step. 1) Getting an Entry object from the LDAP Server by using SearchRunnable.search() method 2) Getting an uniqueMemeber attribute from the Entry 3) getting the values of uniqueMember and adding new value to existing values , added back to Entry. Code Snippet: Method to retrieve Entry: -------------------------------------------------------------------------------------------------- @SuppressWarnings("unchecked") public static Entry getGroupEntry(NewEntryWizard ibr,String groupName) { Entry group=null; //ExportLdifRunnable exLdif = new ExportLdifRunnable("Test", ibr.getSelectedConnection(), new SearchParameter()); StudioProgressMonitor dummyMonitor = new StudioProgressMonitor(new MemberOfStudioProgress()); SearchParameter sp = new SearchParameter(); String names[]=groupName.split(","); names=names[0].split("="); groupName=names[1]; // set default parameter sp.setName(BrowserCoreMessages.model__quick_search_name); Dn parent = ibr.getSelectedEntry().getDn().getParent(); System.out.println("Parent at Initial==="+ibr.getSelectedEntry().getDn().ROOT_DSE); while(!parent.isEmpty()) { parent=parent.getParent(); System.out.println("Parent each Parent==="+parent); } sp.setSearchBase(parent); System.out.println("Parent at end==="+parent); sp.setReturningAttributes(ISearch.NO_ATTRIBUTES); sp.setAliasesDereferencingMethod(ibr.getSelectedConnection().getAliasesDereferencingMethod()); sp.setReferralsHandlingMethod(ibr.getSelectedConnection().getReferralsHandlingMethod()); sp.setCountLimit(ibr.getSelectedConnection().getCountLimit()); sp.setTimeLimit(ibr.getSelectedConnection().getTimeLimit()); sp.setFilter("(&(objectclass=groupOfUniqueNames)(cn="+ groupName+"))"); sp.setScope(SearchScope.SUBTREE); StudioSearchResultEnumeration ne = SearchRunnable.search(ibr.getSelectedConnection(), sp, dummyMonitor); Entry ientry=null; try { while (ne.hasMore()) { ientry = ne.next().getEntry(); //ientry=(IEntry)entry; } } catch (LdapException e1) { // TODO Auto-generated catch block e1.printStackTrace(); System.out.println("Exception message"+e1.getMessage()); } return ientry; } Code Snippet edit the Entry: ------------------------------------------------------------------------------------------- Entry groupEntry=LDAPSearchUtils.getGroupEntry(ocPage.wizard, groupName); org.apache.directory.api.ldap.model.entry.Attribute uniAttribute =groupEntry.get("uniqueMember"); try { uniAttribute.add(selectedEntry.getDn().getName()); } catch (LdapInvalidAttributeValueException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { groupEntry.add(uniAttribute); } catch (LdapException e) { // TODO Auto-generated catch block e.printStackTrace(); } } I understand that the above code is able to add the new uniueMemeber values to groupOfUniqueNames Entry but not storing permanently. Could Please help me in modifying the entry values via back ground code. -- This message was sent by Atlassian Jira (v8.3.2#803003) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@directory.apache.org For additional commands, e-mail: dev-h...@directory.apache.org