Results 1 to 2 of 2

Thread: bug in zimlet zimbra_posixaccount ?

  1. #1
    bunam is offline Intermediate Member
    Join Date
    Oct 2006
    Posts
    21
    Rep Power
    8

    Default bug in zimlet zimbra_posixaccount ?

    Helo,

    We use zimbra with samba so we deploy zimbra_posixaccount, but with 1000+ users (provisioned by an other code in php by soap) when we try to create new user, in the zimbra administration interface, the "next id" procedure fail and return always 1000. We think there is a trouble in this code :
    /opt/zimbra/jetty/webapps/service/zimlet/zimbra_posixaccount/zimbra_posixaccount.js
    Code:
    ZaPosixAccount.getNextUid = function () {
    	var soapDoc = AjxSoapDoc.create("GetLDAPEntriesRequest", "urn:zimbraAdmin", null);	
    	soapDoc.set("ldapSearchBase", zimbra_posixaccount.ldapSuffix);
    	soapDoc.set("query", "(objectClass=posixAccount)");	
    	soapDoc.set("sortBy", ZaPosixAccount.A_uidNumber);	
    	soapDoc.set("sortAscending", "false");		
    	soapDoc.set("limit", "1");			
    	var getPosixAccountsCommand = new ZmCsfeCommand();
    	var params = new Object();
    	params.soapDoc = soapDoc;	
    	var nextId = !isNaN(zimbra_posixaccount.uidBase) ?  parseInt(zimbra_posixaccount.uidBase) + 1 : 10001;
    	try {
    		var resp = getPosixAccountsCommand.invoke(params).Body.GetLDAPEntriesResponse.LDAPEntry[0];
    		if(resp) {
    			var acc = new ZaPosixAccount(new Object());;
    			acc.initFromJS(resp);
    			nextId = parseInt(acc.attrs[ZaPosixAccount.A_uidNumber])+1;
    		}
    	} catch (ex) {
    		//do nothing - fallback to default id for now, ideally should show a warning
    	}
    	return 	nextId;
    }
    we think this code sort the result by alphanumerical order and not numerical order
    Code:
    	var soapDoc = AjxSoapDoc.create("GetLDAPEntriesRequest", "urn:zimbraAdmin", null);	
    	soapDoc.set("ldapSearchBase", zimbra_posixaccount.ldapSuffix);
    	soapDoc.set("query", "(objectClass=posixAccount)");	
    	soapDoc.set("sortBy", ZaPosixAccount.A_uidNumber);	
    	soapDoc.set("sortAscending", "false");		
    	soapDoc.set("limit", "1");
    so 999 is greater than 1xxx
    and the next id returned by this code is 999+1 = 1000

    I think it could be cool if we can specify the type of sort
    Code:
    	soapDoc.set("sortType", "num");
    or the sort function detect by them self the type of the column and switch to the right sort.

    What did you think about that we find ?

    Thank's for reading me

  2. #2
    lfasci is offline Trained Alumni
    Join Date
    Jul 2006
    Location
    Pisa
    Posts
    135
    Rep Power
    9

    Default

    I solved on the javascript side with the following function, I used a similar one for the posix group.

    ZaPosixAccount.getNextUid = function () {
    var soapDoc = AjxSoapDoc.create("GetLDAPEntriesRequest", "urn:zimbraAdmin", null);
    soapDoc.set("ldapSearchBase", zimbra_posixaccount_ext.ldapSuffix);
    soapDoc.set("query", "(objectClass=posixAccount)");
    soapDoc.set("sortBy", ZaPosixAccount.A_uidNumber);
    //soapDoc.set("sortAscending", "false");
    //soapDoc.set("limit", "1");
    var getPosixAccountsCommand = new ZmCsfeCommand();
    var params = new Object();
    params.soapDoc = soapDoc;
    var nextId = !isNaN(zimbra_posixaccount_ext.uidBase) ? parseInt(zimbra_posixaccount_ext.uidBase) + 1 : 10001;
    try {
    // prendo tutti i posixaccount
    var tmp = getPosixAccountsCommand.invoke(params).Body.GetLDA PEntriesResponse.LDAPEntry;
    //popUpProperties(resp);
    // debugger;
    var maxId = 0;
    for(var i=0;i<tmp.length;i++){
    var resp = tmp[i];
    if(resp) {
    var acc = new ZaPosixAccount(new Object());;
    acc.initFromJS(resp);
    //nextId = parseInt(acc.attrs[ZaPosixAccount.A_uidNumber])+1;
    var tempId = parseInt(acc.attrs[ZaPosixAccount.A_uidNumber]);
    if (tempId > maxId) {
    maxId = tempId;
    }
    }
    }
    maxId = maxId + 1;
    nextId = maxId;
    } catch (ex) {
    //do nothing - fallback to default id for now, ideally should show a warning
    }
    return nextId;
    }
    Last edited by lfasci; 01-27-2011 at 09:56 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 03-05-2010, 01:13 AM
  2. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  3. Samba and POSIX undeploy problem
    By catnipper in forum Zimlets
    Replies: 0
    Last Post: 09-02-2009, 10:51 AM
  4. Outlook 2007 Beta error
    By bersrker in forum Zimbra Connector for Outlook
    Replies: 13
    Last Post: 07-17-2008, 07:38 AM
  5. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •