IBM Verify

IBM Verify

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

How to get replication pending change count and replication status using com.ibm.security.access.ldap.utils.AttributeUtil.search() method

  • 1.  How to get replication pending change count and replication status using com.ibm.security.access.ldap.utils.AttributeUtil.search() method

    Posted Fri April 07, 2023 02:03 AM

    Hi All,

    I am trying to get the IBM ISDS LDAP replication pending change count and replication status using java doc AttributeUtil search method and classes by creating the mapping rule in ISVA.

    • com.ibm.security.access.ldap.utils.AttributeUtil.

      I am providing the mapping rule code that I have tried to get the replication pending change count and replication status. But the code below is returning the other parameters of replications and not the replication pending change count and replication status.

      importClass(Packages.com.tivoli.am.fim.trustserver.sts.utilities.IDMappingExtUtils);
      importClass(Packages.com.ibm.security.access.server_connections.ServerConnectionFactory);
      importClass(Packages.com.tivoli.am.fim.trustserver.sts.utilities.OAuthMappingExtUtils);
       
      importClass(Packages.com.tivoli.am.fim.trustserver.sts.uuser.Attribute);
      importPackage(Packages.com.tivoli.am.fim.trustserver.sts.utilities);
      importClass(Packages.com.ibm.security.access.user.User);
      importClass(Packages.com.ibm.security.access.ldap.utils.AttributeUtil);
       
      importClass(Packages.com.tivoli.am.fim.trustserver.sts.uuser.Attribute);
      importClass(Packages.com.tivoli.am.fim.trustserver.sts.uuser.ContextAttributes);
       
      IDMappingExtUtils.traceString("Entering  Replication Info");
       
      success.setValue(false);
       
       
       
      IDMappingExtUtils.traceString("Inside  :::");
      var attrUtil = new AttributeUtil();
      var contextAttr = new ContextAttributes();
      var myLDAPConnection = ServerConnectionFactory.getLdapConnectionByName("LDAPProd");
      IDMappingExtUtils.traceString("TmyLDAPConnection:::"+myLDAPConnection);
      attrUtil.init(myLDAPConnection,"LDAPProd","o=companyName,c=ae");
      var filter = "(&(objectclass=ibm-repl*nt)(objectClass=ibm-replicationagreement))";
      IDMappingExtUtils.traceString("filter :::"+filter);
      var searchAttrs = ['ibm-replicationLastChangeId'];
      var searched = attrUtil.search('O=companyName,C=AE', filter, searchAttrs);
      var result = searched.getNamingEnumeration();
      var responseControl = searched.getResponseControls();
      IDMappingExtUtils.traceString("responseControl::: " + responseControl);
      if(responseControl != null){
         while (responseControl.hasMore()) {
          var attrsResponse = responseControl.next().getAttributes();
          IDMappingExtUtils.traceString("Iterating each attrsResponse::: " + attrs);
         }
      }
       
      IDMappingExtUtils.traceString("after search result : " + result);
      while (result.hasMore()) {
          var attrs = result.next().getAttributes();
         if(attrs.get("ibm-replicationLastChangeId")){
                IDMappingExtUtils.traceString(attrs.get("ibm-replicationLastChangeId"));
                IDMappingExtUtils.traceString(":::::::::::::::::::::::::::::::::::::");
                IDMappingExtUtils.traceString(attrs.get("ibm-replicationLastChangeId").get());
           }
         
          //var attrs = result.next().getAttributeValueByName('ibm-replicationLastChangeId');
          IDMappingExtUtils.traceString("Iterating each attributes : " + attrs);
      }
      var getContextReplicaInfo= contextAttr.getAttributeValueByName('ibm-replicationLastChangeId');
      IDMappingExtUtils.traceString("contextGetReplicaInfo Value::: " +getContextReplicaInfo);
      attrUtil.close();

      But I am getting the below for this code.
      Output: -
      "{ibm-replicamethod=ibm-replicamethod: 1, ibm-replicaconsumerid=ibm-replicaconsumerid: 7bf77940-6d61-103b-9d7a-f40c0b10f439, ibm-replicationonhold=ibm-replicationonhold: FALSE, ibm-replicaurl=ibm-replicaurl: ldap://hostname:389, ibm-replicacredentialsdn=ibm-replicacredentialsdn: cn=mycreds,cn=replication,cn=IBMpolicies, objectclass=objectclass: ibm-replicationagreement, top, cn=cn: hostname:389}"

      Please any me know how can get the replication pending change count and replication status.





    ------------------------------
    Manu kumar M
    ------------------------------


  • 2.  RE: How to get replication pending change count and replication status using com.ibm.security.access.ldap.utils.AttributeUtil.search() method

    Posted Mon April 10, 2023 01:43 PM

    Hi Manu,
    One suggestion on the filter - you could just use "(objectClass=ibm-replicationagreement)", in place of "(&(objectclass=ibm-repl*nt)(objectClass=ibm-replicationagreement))" as the first part is redundant.

    Now coming to "searchAttrs", the returned response is same as when there is no explicit "searchAttrs" are mentioned. You may want to see ldap server side audit.log when this request gets received. For some reason the java code is not sending in "searchAttrs". You need to explicitly ask for the searchAttrs: ibm-replicationState and ibm-replicationPendingChangeCount. Also ibm-replicationLastResult will be useful.



    ------------------------------
    Ramamohan Reddy
    ------------------------------



  • 3.  RE: How to get replication pending change count and replication status using com.ibm.security.access.ldap.utils.AttributeUtil.search() method

    Posted Tue April 11, 2023 01:41 AM

    Hi Ramamohan,

    Thank you for reverting back. Sorry in the above I wrongly mentioned that search method as three parameters, but this attrUtil.attrUtil as only two parameters   searched = attrUtil.search('O=companyName,C=AE', filter)". I understand that I need to send "searchAttrs" to get the ibm-replicationPendingChangeCount attributes. When I am calling search method I need to send "searchAttrs". But I am not aware how to send this "searchAttrs" in search method because it has

    Javadoc search method

     only two parameters. Please let me know how can I send "searchAttrs" for the method attrUtil.search('O=companyName,C=AE', filter)".

    Regards,
    Manu



    ------------------------------
    Manu kumar M
    ------------------------------