Author: amit Date: 2005-08-15 18:11:12 +0000 (Mon, 15 Aug 2005) New Revision: 421
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=lorikeet&rev=421 Log: Class added for handling Machine Trust Accounts Added: trunk/sangria/src/LatestDesign/classes/AccountManager/MachineTrustAccountClass.py Modified: trunk/sangria/src/LatestDesign/classes/AccountManager/AccountManagerClass.py trunk/sangria/src/LatestDesign/test/test.py Changeset: Modified: trunk/sangria/src/LatestDesign/classes/AccountManager/AccountManagerClass.py =================================================================== --- trunk/sangria/src/LatestDesign/classes/AccountManager/AccountManagerClass.py 2005-08-15 17:18:42 UTC (rev 420) +++ trunk/sangria/src/LatestDesign/classes/AccountManager/AccountManagerClass.py 2005-08-15 18:11:12 UTC (rev 421) @@ -4,26 +4,6 @@ -class UserPrivileges: - - def __init__(self, UserName): - self.UserName = UserName - - def SetUserRight(self, Right): - ''' - Here we fix up the privileges for the user .. (self.UserName) - here code to set the right - but before proceeding it sould be clear that server had to be set to - - enable privileges = yes - and restarted .. - - do that in INIT ... - ''' - pass - - - class User: def SetPassword(self, UserPassword): Added: trunk/sangria/src/LatestDesign/classes/AccountManager/MachineTrustAccountClass.py =================================================================== --- trunk/sangria/src/LatestDesign/classes/AccountManager/MachineTrustAccountClass.py 2005-08-15 17:18:42 UTC (rev 420) +++ trunk/sangria/src/LatestDesign/classes/AccountManager/MachineTrustAccountClass.py 2005-08-15 18:11:12 UTC (rev 421) @@ -0,0 +1,29 @@ + +import sys,os,commands +import string + + +class MachineTrustAccount: + + def __init__(self): + pass + + def AddMachineAccount(self , ClientMachineName , UnixGroupToJoin , UnixPassword , SmbPassword): + + ''' ClientMachineName = NetBIOS name ''' + + cmd = "useradd -p \"%s\" -g \"%s\" -d /dev/null -c \"%s\" -s /bin/false \"%s$\"" %( UnixPassword , UnixGroupToJoin , ClientMachineName , ClientMachineName) + print cmd + ( status, cmd_output ) = commands.getstatusoutput( cmd ) + if status: + print "here" + return 0 + + ## fix up samba password + + cmd = "smbpasswd -a -m \"%s\"" %(ClientMachineName) + ( status, cmd_output ) = commands.getstatusoutput( cmd ) + if status: + return 0 + + return 1 Modified: trunk/sangria/src/LatestDesign/test/test.py =================================================================== --- trunk/sangria/src/LatestDesign/test/test.py 2005-08-15 17:18:42 UTC (rev 420) +++ trunk/sangria/src/LatestDesign/test/test.py 2005-08-15 18:11:12 UTC (rev 421) @@ -16,6 +16,8 @@ from AccountManagerClass import SambaUser from GroupManagerClass import GroupManager +from MachineTrustAccountClass import MachineTrustAccount + from UserPrivilegesClass import UserPrivileges @@ -25,8 +27,13 @@ s = Server("/home/amit/test/smb.conf" , "/usr/sbin/") - s.RestartServer() + # add machine trust account + m = MachineTrustAccount() + ret = m.AddMachineAccount('teromachine' , 'helohelo' , 'regmi' , 'sambaregmi') + print ret +## s.RestartServer() + ## priv = UserPrivileges(s) ## priv.GrantUserPrivilege("pant" , "root" , "amit" , "SeMachineAccountPrivilege")
