r9707: r11080@blu: tridge | 2005-08-28 12:41:12 +1000
authorAndrew Tridgell <tridge@samba.org>
Sun, 28 Aug 2005 02:38:11 +0000 (02:38 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:52 +0000 (13:34 -0500)
 make sure we leave the account enabled after creating a new user

source/scripting/libjs/provision.js

index 0bcb2fa761e4a69977104729ef510e16d42afb79..afa5adaa9f58ea7c4b1074a266ca7213d0f41d8b 100644 (file)
@@ -317,6 +317,28 @@ function searchone(ldb, expression, attribute)
        return res[0][attribute];
 }
 
+/*
+  modify an account to remove the 
+*/
+function enable_account(ldb, user_dn)
+{
+       var attrs = new Array("userAccountControl");
+       var res = ldb.search(NULL, user_dn, ldb.SCOPE_ONELEVEL, attrs);
+       assert(res.length == 1);
+       var userAccountControl = res[0].userAccountControl;
+       userAccountControl = userAccountControl - 2; /* remove disabled bit */
+       var mod = sprintf("
+dn: %s
+changetype: modify
+replace: userAccountControl
+userAccountControl: %u
+", 
+                         user_dn, userAccountControl);
+       var ok = ldb.modify(mod);
+       return ok;      
+}
+
+
 /*
   add a new user record
 */
@@ -385,7 +407,10 @@ member: %s
                return false;
        }
 
-       return true;
+       /*
+         modify the userAccountControl to remove the disabled bit
+       */
+       return enable_account(ldb, user_dn);
 }