LDAP Business operation - How to loop through EnsLib.LDAP.Message.Results and get all the attributes
I am trying to figure out how to loop through the EnsLib.LDAP.Message.Results to get all the attributes. From router I am passing EnsLib.LDAP.Messge.Search as the request param. Response is EnsLib.LDAP.Message.Results. I am invoking the EnsLib.LDAP.Messge.Search BO.
At the BP level, trying to figure out how to extract all the attributes for a EnsLib.LDAP.Message.results
Product version: IRIS 2022.1
Something like this:
#dim results As EnsLib.LDAP.Message.Results for i=1:1:results.Results.Count() { #dim result As EnsLib.LDAP.Message.Result set result = results.Results.GetAt(i) write "DN: ", result.DN, ! write "Attributes: ", ! for j=1:1:result.Attributes.Count() { #dim atribute As EnsLib.LDAP.Message.Attribute set atribute = result.Attributes.GetAt(j) write $$$FormatText(" - Name: %1, Result: %2, Value: %3", atribute.Name, atribute.Result, atribute.Value), ! } }
Eduard - thank you. That really helped. I can open a new thread if needed but do you know if we can use the Modify class to reset an user's password?
Edit: Found this in %SYS.LDAP but was wondering if I can do this with the existing operation EnsLib.LDAP.Operation.Standard without creating another inherited class.
s password="NewPassword"
s ChangePassword=$zcvt(""""_password_"""","o","UnicodeLittle")
s Attr1=$lb(130,"unicodePwd",$lb(ChangePassword))
s Attributes=$lb(Attr1)
s Status=##Class(%SYS.LDAP).ModifyExts(LD,DN,Attributes,"","")