Editing a dojox DataGrid connected to a JsonRest store

A little bit of a problem with using a dojox.grid.DataGrid connected to a dojo.store.JsonRest data store.

Note that dojox.grid is officially abandoned so it’s not really a very good idea to use it anyway – should be using dgrid or GridX instead.

If you edit a cell value then timing issues mean that although the change is held (and will be saved when you store.save()) the displayed value reverts to the original.

One way around this is to make use of onApplyCellEdit.

You can also use this function to call this.store.save() if you want to save after every change.

There also appears to be a problem with adding rows not displaying as well.

 function saveCellEdit(inValue, inRowIndex, inAttrName){
	/*
	 this.store.save();
	 */
	var data = this.getItem(inRowIndex);
	data[inAttrName] = inValue;
  };
  /*create a new grid*/
  var grid = new DataGrid({
			id : 'grid',
			store : store,
			structure : layout,
			rowSelector : '20px',
			onApplyCellEdit: saveCellEdit
		});

Some relevant links:

Using the LDAP Password Modify extended operation with Spring LDAP

If you want to change the password for a given user in an LDAP repository then you need to worry about the format in which it is being stored otherwise you will end up with the password held in plain text (although base64 encoded)

Using the password modify extended operation (rfc3062) allows OpenLDAP, in this case, to manage the hashing of the new password.

If you don’t use the extension then you have to hash the value yourself.
This code stores the new password as plaintext and treats the password as if it is any other attribute.
You can implement hashing yourself e.g. by prepending {MD5} and using the base64 encoded md5 hash of the new password – see this forum entry

Don’t use this!

	DistinguishedName dn = new DistinguishedName(dn_string);
	Attribute passwordAttribute = new BasicAttribute(passwordAttr,
			newPassword);
	ModificationItem[] modificationItems = new ModificationItem[1];
	modificationItems[0] = new ModificationItem(
			DirContext.REPLACE_ATTRIBUTE, passwordAttribute);
/*
	Attribute userPasswordChangedAttribute = new BasicAttribute(
			LDAP_PASSWORD_CHANGE_DATE, format.format(convertToUtc(null)
					.getTime()) + "Z");
	ModificationItem newPasswordChanged = new ModificationItem(
			DirContext.REPLACE_ATTRIBUTE, userPasswordChangedAttribute);
	modificationItems[1] = newPasswordChanged;
	*/
	getLdapTemplate().modifyAttributes(dn, modificationItems);

 

This example uses the extended operation which means that password will be stored according to the OpenLDAP settings i.e. SSHA by default.

The ldap template here is an instance of org.springframework.ldap.core.LdapTemplate

 ldapTemplate.executeReadOnly(new ContextExecutor() {
   public Object executeWithContext(DirContext ctx) throws NamingException {
      if (!(ctx instanceof LdapContext)) {
            throw new IllegalArgumentException(
               "Extended operations require LDAPv3 - "
               + "Context must be of type LdapContext");
      }
      LdapContext ldapContext = (LdapContext) ctx;
      ExtendedRequest er = new ModifyPasswordRequest(dn_string, new_password);
      return ldapContext.extendedOperation(er);
    }
   });

This thread gives an idea of what is required however the ModifyPasswordRequest class available from here actually has all the right details implemented.

You will find that other LDAP libraries e.g. ldapChai use the same ModifyPasswordRequest class