Author: sree
Date: 2006-08-20 17:19:55 +0000 (Sun, 20 Aug 2006)
New Revision: 17621

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17621

Log:
Added function user_group_get_all() to enumerate all groups.

Added server calls for setting user profile and general information.

Added function user_props_update() as support functions for user properties 
dialog.

User properties dialog now saves information.


Modified:
   branches/SOC/sree/ui/usermgmt.esp
   branches/SOC/sree/ui/userprop.js


Changeset:
Modified: branches/SOC/sree/ui/usermgmt.esp
===================================================================
--- branches/SOC/sree/ui/usermgmt.esp   2006-08-20 17:08:37 UTC (rev 17620)
+++ branches/SOC/sree/ui/usermgmt.esp   2006-08-20 17:19:55 UTC (rev 17621)
@@ -4,6 +4,7 @@
 libinclude("server_call.js");
 libinclude("usermgmt.js");
 
+// enumerate all users
 function __user_get_all(attrs)
 {    
     printf("user_get_all\n");
@@ -13,7 +14,7 @@
     var results;
 
     if(attrs.length == 0)
-       results = sam.ldb.search(NULL, user_dn);
+       results = sam.ldb.search('(objectClass=user)', user_dn);
     else
        results = sam.ldb.search('(objectClass=user)', user_dn, 
sam.ldb.SCOPE_DEFAULT, attrs);
 
@@ -22,6 +23,26 @@
     return results;
 }
 
+// enumerate all groups
+function __user_group_get_all(attrs)
+{    
+    printf("user_group_get_all\n");
+    var sam = user_init(session.authinfo.session_info, 
session.authinfo.credentials);
+
+    var user_dn = sprintf("%s", sam.domain_dn);
+    var results;
+
+    if(attrs.length == 0)
+       results = sam.ldb.search('(objectClass=group)', user_dn);
+    else
+       results = sam.ldb.search('(objectClass=group)', user_dn, 
sam.ldb.SCOPE_DEFAULT, attrs);
+
+    printVars(results);
+    user_deinit(sam);
+    return results;
+}
+
+
 function __user_add(username, fullname, description, password, flags, 
otherflags, unixname)
 {
     printf("user_add: %s, %s, %s, %s, %d, %d, %s\n", username, fullname, 
description
@@ -106,6 +127,52 @@
     return result;   
 }
 
+function __user_general_set(username, fullname, description, flags, unixname)
+{
+    printf("user_general_set: %s, %s, %s, %s, %d, %s\n", username, fullname, 
description, flags, unixname); 
+    var sam = user_init(session.authinfo.session_info, 
session.authinfo.credentials);
+    result = user_general_set(sam, username, fullname, description, flags, 
unixname);
+
+    user_deinit(sam);
+    return result;
+}
+
+function __user_profile_set(username, profilepath, logonscript, homepath, 
homedrive)
+{
+    printf("user_profile_set: %s, %s, %s, %s, %s, %s\n", username, 
profilepath, logonscript, homepath, homedrive); 
+    var sam = user_init(session.authinfo.session_info, 
session.authinfo.credentials);
+    result = user_profile_set(sam, username, profilepath, logonscript, 
homepath, homedrive);
+    user_deinit(sam);
+    return result;
+}
+
+function __user_props_update(username, userprops)
+{
+    printf("user_props_update: \n");
+    printVars(userprops);    
+    var sam = user_init(session.authinfo.session_info, 
session.authinfo.credentials);
+    var g = userprops.general;
+    var p = userprops.profile;
+    if(!g || !p) return false;
+
+    //TODO: nested transactions do not yet work
+    sam.ldb.transaction_start();
+    printf("setting general properties ");
+    var r = user_general_set(sam, username, g.fullname, g.description, 
g.flags, g.unixname);
+    if(!r) { sam.ldb.transaction_cancel(); return false; }
+    printf("done\n");
+
+    printf("setting profile properties ");
+    if(p.homedrive == "*") p.homedrive = "";
+    r = user_profile_set(sam, username, p.profilepath, p.logonscript, 
p.homepath, p.homedrive);
+    if(!r) { sam.ldb.transaction_cancel(); return false; }
+    printf("done\n");
+
+    r = sam.ldb.transaction_commit();
+    user_deinit(sam);
+    return r;
+}
+
 var call = servCallObj();
 call.add('user_get_all', __user_get_all);
 call.add('user_add', __user_add);
@@ -116,5 +183,9 @@
 call.add('user_group_get', __user_group_get);
 call.add('user_group_add', __user_group_add);
 call.add('user_group_remove', __user_group_remove);
+call.add('user_profile_set', __user_profile_set);
+call.add('user_general_set', __user_general_set);
+call.add('user_group_get_all', __user_group_get_all);
+call.add('user_props_update', __user_props_update);
 call.run();
 %>

Modified: branches/SOC/sree/ui/userprop.js
===================================================================
--- branches/SOC/sree/ui/userprop.js    2006-08-20 17:08:37 UTC (rev 17620)
+++ branches/SOC/sree/ui/userprop.js    2006-08-20 17:19:55 UTC (rev 17621)
@@ -52,10 +52,37 @@
     var chkAccountDisabled = new QxCheckBox("Account is disabled", "2", "", 
(uac & 2) > 0);
     var chkAccountLocked = new QxCheckBox("Account is locked out", "", "");
 
+    function pack()
+       {
+           var o = new Object();
+           if(!txtUnixname.getValue())
+               {
+                   window.alert("Unixname cannot be empty!");
+                   return null;
+               }
+
+           o.fullname = txtFullname.getValue();
+           o.description = txtDescription.getValue();
+           o.unixname = txtUnixname.getValue();
+
+           //TODO: Implement account locking, next logon change
+           var chkboxes = [chkNoChangePassword, chkNoPasswordExpire, 
chkAccountDisabled];
+           var uaf = 0;
+           for(var i = 0; i < chkboxes.length; i++)
+               {
+                   if(chkboxes[i].getChecked())
+                       uaf = uaf | chkboxes[i].getValue();
+               }
+
+           o.flags = uaf;
+           return o;
+       }
+
     bl.add(user);
     bl.add(gl);
     bl.add(chkChangePassword, chkNoChangePassword, chkNoPasswordExpire, 
chkAccountDisabled, chkAccountLocked);
     gp.add(bl);
+    gp.pack = pack;
     tv.getPane().add(gp);
 }
 
@@ -90,6 +117,7 @@
     bl.add(new QxLabel("Member of:", "m"));
 
     var grpList = new QxList;
+    grpList.getManager().setMultiSelection(false);
     grpList.setHeight("80%");
 
     var bl2 = new QxBoxLayout(QxConst.ORIENTATION_HORIZONTAL);
@@ -261,6 +289,25 @@
            txtLocalPath.setValue(user_data['homeDirectory']);
        }
 
+
+    function pack()
+       {
+           var o = new Object();
+           if(rm.getSelected() == rb2 && !txtNetworkPath.getValue())
+               {
+                   window.alert("No network path specified!");
+                   return null;
+               }
+           
+           o.profilepath = txtProfilePath.getValue();
+           o.logonscript = txtLogonScript.getValue();
+           o.homepath = (rm.getSelected() == rb1) ? txtLocalPath.getValue() : 
txtNetworkPath.getValue();
+           //TODO: remove the *, put in to workaround a bug
+           o.homedrive = (rm.getSelected() == rb2) ? 
cbDrive.getSelected().getLabel() : "*";
+           
+           return o;
+       }
+
     gl2.add(rb1, 0, 0);
     gl2.add(txtLocalPath, 1, 0);
     gl2.add(rb2, 0, 1);
@@ -270,6 +317,7 @@
     fs2.add(gl2);
     bl.add(fs1, fs2);
     pp.add(bl);
+    pp.pack = pack;
     tv.getPane().add(pp);    
 }
 
@@ -321,9 +369,32 @@
     btnCancel.setWidth(80);
     btnApply.setWidth(80);
 
+    function _save_props(close)
+       {
+           var gp = tv.getPane().getChildren()[0];
+           var pp = tv.getPane().getChildren()[2];
+           
+           var props = new Object();
+           props.general = gp.pack();
+           if(props.general == null) return;
+           props.profile = pp.pack();
+           if(props.profile == null) return;
+
+           server_call_url('/user_manager/usermgmt.esp', 'user_props_update',
+                           function (result) {
+               if(result)
+                   {
+                       if(close) w1.close();
+                   }
+               else
+                   window.alert("Could not update properties");
+           }, username, props);            
+       }
+
     btnCancel.addEventListener("click", function() { w1.close(); });
+    btnOk.addEventListener("click", function() { _save_props(true); });
+    btnApply.addEventListener("click", function () { _save_props(false); });
 
-
     bl2.add(btnOk);
     bl2.add(btnCancel);
     bl2.add(btnApply);

Reply via email to