svn commit: samba r16617 - in branches/SOC/sree: .
sree at samba.org
sree at samba.org
Wed Jun 28 07:43:44 GMT 2006
Author: sree
Date: 2006-06-28 07:43:43 +0000 (Wed, 28 Jun 2006)
New Revision: 16617
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16617
Log:
new function user_general_set() allows changing user's general properties
Modified:
branches/SOC/sree/usermgmt.js
Changeset:
Modified: branches/SOC/sree/usermgmt.js
===================================================================
--- branches/SOC/sree/usermgmt.js 2006-06-28 05:00:09 UTC (rev 16616)
+++ branches/SOC/sree/usermgmt.js 2006-06-28 07:43:43 UTC (rev 16617)
@@ -305,7 +305,7 @@
if(user == false)
{
- print("Failed to get user's groups, no such user?\n");
+ print("No such user\n");
sam.ldb.transaction_cancel();
return false;
}
@@ -368,3 +368,88 @@
return(sam.ldb.transaction_commit());
}
+
+// set user's general properties
+// again, set null to leave as is, "" to erase
+// only full name and description can be erased
+// username CANNOT be changed with this function
+// note: flags is absolute value
+function user_general_set(sam, username, fullname, description, flags, unixname)
+{
+ var user_dn = sprintf("CN=%s,CN=Users,%s",
+ username, sam.domain_dn);
+
+ var general = new Array();
+ var k = 0;
+
+ sam.ldb.transaction_start();
+
+ user = user_get(sam, username, new Array("displayName"));
+
+ if(user == false)
+ {
+ print("No such user\n");
+ sam.ldb.transaction_cancel();
+ return false;
+ }
+
+ if(fullname != null)
+ {
+ if(fullname == "")
+ general[k] = "delete: displayName";
+ else
+ general[k] = "replace: displayName\ndisplayName: " + fullname;
+ k = k + 1;
+ }
+
+
+ if(description != null)
+ {
+ if(description == "")
+ general[k] = "delete: description";
+ else
+ general[k] = "replace: description\ndescription: " + description;
+ k = k + 1;
+ }
+
+
+ if(unixname != null)
+ {
+ if(unixname == "")
+ {
+ print("unixname can't be empty!\n");
+ sam.ldb.transaction_cancel();
+ return false;
+ }
+ else
+ general[k] = "replace: unixName\nunixName: " + unixname;
+
+ k = k + 1;
+ }
+
+ if(flags != null)
+ {
+ general[k] = "replace: userAccountControl\nuserAccountControl: " + flags;
+
+ k = k + 1;
+ }
+
+ if(k == 0)
+ {
+ print("No details provided\n");
+ sam.ldb.transaction_cancel();
+ return false;
+ }
+
+ var ldifmod = "dn: " + user_dn + "\nchangeType: modify\n" + join("\n-\n", general) + "\n";
+
+ if(sam.ldb.modify(ldifmod) != true)
+ {
+ print("Failed to set user's general settings!\n");
+ sam.ldb.transaction_cancel();
+ return false;
+ }
+
+ return(sam.ldb.transaction_commit());
+}
+
More information about the samba-cvs
mailing list