IRISLIB database
EditEntry Class Reference

WARNING: This Class and its methods has been deprecated, please use the SYS.LDAP class. More...

Inheritance diagram for EditEntry:
Collaboration diagram for EditEntry:

Public Member Functions

_.Library.Status Add (_.Library.String attribute, _.Library.RawString value, _.Library.Boolean binary)
 Add a value to an attribute. More...
 
_.Library.Status Commit ()
 Commit the changes. More...
 
_.Library.Status Remove (_.Library.String attribute, _.Library.RawString value, _.Library.Boolean binary)
 Remove an attribute value. More...
 
_.Library.Status Replace (_.Library.String attribute, _.Library.RawString value, _.Library.Boolean binary)
 Replace an attribute value. More...
 
- Public Member Functions inherited from RegisteredObject
_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 This callback method is invoked when the current object is added to the SaveSet,. More...
 
_.Library.Status OnClose ()
 This callback method is invoked by the <METHOD>Close</METHOD> method to. More...
 
_.Library.Status OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned)
 This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More...
 
_.Library.Status OnNew ()
 This callback method is invoked by the <METHOD>New</METHOD> method to. More...
 
_.Library.Status OnValidateObject ()
 This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More...
 

Additional Inherited Members

- Static Public Attributes inherited from RegisteredObject
 CAPTION = None
 Optional name used by the Form Wizard for a class when generating forms. More...
 
 JAVATYPE = None
 The Java type to be used when exported.
 
 PROPERTYVALIDATION = None
 This parameter controls the default validation behavior for the object. More...
 

Detailed Description

WARNING: This Class and its methods has been deprecated, please use the SYS.LDAP class.




Edit/Modify an existing LDAP Entry

The following shows an example of editting an entry:

Set err="" Set session=##class(Net.LDAP.Client.Session).New() Set DC="DC=testldap,DC=com" Set c=session.Connect("lx2",0,"CN=admin,"_DC,"password", 0) If ($$$ISERR(c)) { Do DecomposeStatus^apiOBJ(c,.err) Write "Failed to connect : err : ", err(err),! Quit } Write "Connected to (",DC,")",!

;; Create a test entry ;; Build attributes to be added to the entry Set p=session.GetPropList() Set c=p.Insert("objectclass","organizationalRole") w:(c'=$$$OK) "objclass attrib insert failed!!",! Set cn="test4" Set c=p.Insert("cn",cn) w:(c'=$$$OK) "cn attrib insert failed!!",! Set DN="cn="_cn_","_DC Set c=session.AddNewEntry(DN,p) If ($$$ISERR(c)) { Do DecomposeStatus^apiOBJ(c,.err) Write "Failed to add/create a new entry(",DN,") : err : ", err(err),! } else { Write "Entry added (",DN,")",! } ;; Edit/Modify DN s ed=session.EditEntry(DN) ;; Modifiy "description" attrib with multiple value s mv=session.GetValueList() s c=mv.Insert("Modified for testing!!") w:(c'=$$$OK) "1- multi value insert failed!!",! s:('$$$ISERR(c)) c=mv.Insert("Last updated - "_$zdt($ztimestamp)) w:(c'=$$$OK) "2- multi value insert failed!!",! ;; Queue an add of a multi-value "description" attrib, ;; and replace "postaladdress" attrib value s:('$$$ISERR(c)) c=ed.Add("description",mv) s:('$$$ISERR(c)) c=ed.Replace("postalAddress","123 - New addr") if ($$$ISERR(c)) { d DecomposeStatus^apiOBJ(c,.err) W "--- Failed to edit DN(",DN,") : err : ", err(err),! } else { w "Edits Q-ed ok!!",! } ;; Commit the edits s c=ed.Commit() if ($$$ISERR(c)) { d DecomposeStatus^apiOBJ(c,.err) W "--- Failed to commit DN(",DN,") changes : err : ", err(err),! } else { w "Committed ok!!",! } ;; Display the changes ;; Get all "ObjectClass", "postalAddress", "description", and "cn" in DC ;; build a list of desired attributes Set sl=session.GetStringList() Do sl.InsertStr("ObjectClass","cn","postalAddress","description") Set session.MaxItems=100 ;; specify max number of results Set ents=session.Search(DC,scope, "(ObjectClass=*)",sl,1000) If ('$IsObject(ents)) { Do DecomposeStatus^apiOBJ(ents,.err) Write "Search failed : err : ", err(err),! } else { Write !,"Search result:",! Set count=0 Set entDN="" For { ; iterate through returned entries Set ent=ents.GetNext(.entDN) Quit:(entDN="") Set count=count+1 Write " ",count," - Entry(",entDN,")",! if ($IsObject(ent)) { Set attrNM="" For { ; iterate through each attribute of an entry Set val=ent.GetNext(.attrNM) Quit:(attrNM="") Write " Ent(",entDN,"), attr(",attrNM,")",! ;; iterate through values associated with each attribute For i=1:1:val.GetNumItems() { Write " ",i," - Value(",val.GetValue(i),")",! } } } else { Quit ;; list end } } Write !,"Search done!! Count == ",count,! } Set c=session.DeleteEntry(DN) If ($$$ISERR(c)) { Do DecomposeStatus^apiOBJ(c,.err) Write "Failed to delete entry(",DN,") : err : ", err(err),! } else { Write "Delete entry (",DN,")",! }

Member Function Documentation

◆ Add()

_.Library.Status Add ( _.Library.String  attribute,
_.Library.RawString  value,
_.Library.Boolean  binary 
)

Add a value to an attribute.

attribute Attribute to change

value New value

The value could be string, stream, or a binary blub

If attribute doesn't exist in the entry, the attribute will be added

This change is committed by the Commit method

◆ Commit()

_.Library.Status Commit ( )

Commit the changes.

Applies the pending changes. On success, resets/clears the change list.

◆ Remove()

_.Library.Status Remove ( _.Library.String  attribute,
_.Library.RawString  value,
_.Library.Boolean  binary 
)

Remove an attribute value.

attribute Attribute to change

value Value to be deleted

The value could be string, stream, or a binary blub

If no value is provided, it will remove the attribute and all values

This change is committed by the Commit method

◆ Replace()

_.Library.Status Replace ( _.Library.String  attribute,
_.Library.RawString  value,
_.Library.Boolean  binary 
)

Replace an attribute value.

attribute Attribute to change

value New value of the attribute

The value could be string, stream, or a binary blub

If attribute doesn't exist in the entry, the attribute will be added

This change is committed by the Commit method