Class Reference
%Net.LDAP.Client.EditEntry
Server:basexml
Instance:SOAXML
User:UnknownUser
 
-
  [BASEXML] >  [%Net] >  [LDAP] >  [Client] >  [EditEntry]
Private  Storage

class %Net.LDAP.Client.EditEntry extends %RegisteredObject

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,")",!
	    }

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
5


Summary

Methods
%%OIDGet %AddToSaveSet %ClassIsLatestVersion %ClassName
%ConstructClone %DispatchClassMethod %DispatchGetModified %DispatchGetProperty
%DispatchMethod %DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty
%Extends %GetParameter %IsA %IsModified
%New %NormalizeObject %ObjectModified %OriginalNamespace
%PackageName %RemoveFromSaveSet %SerializeObject %SetModified
%ValidateObject Add Commit Remove
Replace


Methods

• method Add(attribute As %String, value As %CacheString, binary As %Boolean = 0) as %Status
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

• method Commit() as %Status
Commit the changes.

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

• method Remove(attribute As %String, value As %CacheString = "", binary As %Boolean = 0) as %Status
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

• method Replace(attribute As %String, value As %CacheString, binary As %Boolean = 0) as %Status
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