Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-10-2010, 01:54 AM
Intermediate Member
 
Posts: 18
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
Reply With Quote
  #2 (permalink)  
Old 01-27-2011, 05:20 AM
Trained Alumni
 
Posts: 127
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;
}
__________________
http://www.seacom.it

Last edited by lfasci; 01-27-2011 at 08:56 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.