Thanks for replying.  I actually don't know what you exactly mean by `what type 
of AttributeType are you using for this
attribute`.  So, I'll try to show some code and explain what my code is doing 
outside of what i don't show...  I have it OO designed out to be able to manage 
our AD for multiple styles of users, so it is hard to show all at once.

Here is a snippet of our "Search" method

        SearchRequest searchRequest = new SearchRequestImpl();
        searchRequest.setBase(new Dn(searchBaseDn));
        searchRequest.setFilter(filter);
        searchRequest.setScope(SearchScope.SUBTREE);
        searchRequest.addAttributes((String[]) attributes.toArray(new 
String[0]));
        searchRequest.addControl(pagedSearchControl);

        cursor = new EntryCursorImpl(ldapConn.search(searchRequest));

        while (cursor.next()) {
          try {
            Entry result = cursor.get();
            if (offset == null || offset.equals(pagesLooped)) {
              if (processRanges) {
                processRangeAttributes(ldapConn, result, attributes, 
searchBaseDn);
              }
              results.add(result);
              sizeOfResult++;
            }
          } catch (CursorLdapReferralException clre) {
            do {
              // ignoring referrals
            } while (clre.skipReferral());
          }
        }



attributes.toArray logs out like this ==> [accountExpires, 
altSecurityIdentities, badPasswordTime, badPwdCount, cn, distinguishedName, 
extensionAttribute2, mS-DS-ConsistencyGuid, msDS-KeyVersionNumber, 
msDS-SupportedEncryptionTypes, objectClass, objectGuid, objectSid, 
primaryGroupId, pwdLastSet, sAMAccountName, uid, userAccountControl, 
userPrincipalName, whenChanged, whenCreated]

Once the search method is complete, it returns the "entry" -or collection of 
entrys to a method that runs that entry through a conversion process

Below is my current mess​ of code while trying to figure out how to manipulate 
the bytes coming back for ms-ds-consistencyguid

 for (Attribute a : entry.getAttributes()) {
     ....

            log.debug("Setting field [" + attributeName + "] with value [" + 
a.get().getString() + "] and field type ["
                + f.getType() + "]");

    .....

            } else if (f.getType().equals(byte[].class)) {

              byte[] theValue;
              if (a.isHumanReadable()) {

                // library is saying ms-ds-consistency is humanreadable

                // in eaduser:
                // objectguid is setup as byte[]
                // ms-ds-consistency is setup as byte[]

                // in ad:
                // objectguid seems to be binary of the value expected
                // ms-ds-consistencyguid is what i'm confused on

                // objectguid is marked isHumanReadable = false -- so it goes 
to else statemnt

                // here is my attempt at changing consistencyguid
                if (attributeName.equals("ms-ds-consistencyguid")) {

                  theValue = Strings.getBytesUtf8(a.get().getString());

                  log.debug("ms-ds-consistencyguid theValue= " + theValue);

                  log.debug("ms-ds-consistencyguid hex of theValue=" + 
Hex.encodeHex(theValue));
                  log.debug(
                      "ms-ds-consistencyguid formattedhex of theValue=" + 
EadConvertUtil.toFormattedHex(theValue));

                  log.debug("ms-ds-consistencyguid json of 
a.get().getString().getBytes()"
                      + g.toJson(a.get().getString().getBytes()));
                } else {

                  theValue = a.get().getString().getBytes();
                  if (attributeName.equals("objectguid")) {
                    log.debug("objectguid ut8encode= " + theValue);
                    log.debug(
                        "objectguid guid= " + 
EadConvertUtil.convertHexToMSGUIDFormat(Strings.utf8ToString(theValue)));
                  }
                }

              } else
                  //****************** THIS WORKS for objectguid but not 
ms-ds-consistency *****************************
                theValue = a.get().getBytes();
              }

              EADTransformationUtil.setForField(entityToPopulate, f, theValue);


    .....
 }




thanks,

Craig Benner


My Calendar in Free/Busy 
View<https://outlook.office365.com/owa/calendar/a547b9cc00cf46ffaaf4072980708...@psu.edu/2f5004b9918c42af84647509f87d174b8638641687214814771/calendar.html>

<https://outlook.office365.com/owa/calendar/a547b9cc00cf46ffaaf4072980708...@psu.edu/2f5004b9918c42af84647509f87d174b8638641687214814771/calendar.html>

https://keybase.io/craigbenner

________________________________
From: Emmanuel Lécharny <elecha...@gmail.com>
Sent: Wednesday, March 24, 2021 9:11 AM
To: api@directory.apache.org <api@directory.apache.org>
Subject: Re: help on retrieving ms-ds-consistencyguid from activedirectory

Hi!

just wondering: what type of AttributeType are you using for this
attribute? It will drive the way it's exposed.

In any case, you should be able to pull the value from the UpValue
field, as it is what is returned without any processing.

Ca you copy/paste the code you use to read this value ?


On 24/03/2021 13:50, Benner, Craig wrote:
> Apache Ldap Api group,
>    I'm working on some code that is using this library to pull directory 
> information out of Active Directory's LDAP.  So far, the library is great and 
> has helped tremendously.  But I've hit a roadblock, I'm trying to pull the 
> attribute ms-ds-consistencyguid, the library is pulling the data.  But the 
> part that I'm not understanding is how to convert the data into the hex value 
> that other applications are showing as the value.
>
> Some information:
> It is being returned as HumanReadable, with an upValue, normValu, h, isHR, 
> and bytes.  I'm trying to use the bytes and convert it but with no luck so 
> far.
>
> Does anyone have any knowledge with respect to this field or how to process 
> this type of field?
>
>
>
>
> thanks,
>
> Craig Benner
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscr...@directory.apache.org
For additional commands, e-mail: api-h...@directory.apache.org

Reply via email to