Changing Admins to standard users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dougancil
    Contributor
    • Apr 2010
    • 347

    Changing Admins to standard users

    Is there a script that can be run to change a admin user to a standard user? I have a group of users who were given admin rights that don't need them and rather than do this manually, I'd prefer to do it with a script if at all possible.
  • computerfox
    Contributor
    • Mar 2010
    • 276

    #2
    Try running this with sudo
    Code:
    #!/bin/python
    import os
    import sys
    
    class editor:
     path=None;
     group=None;
     users=None;
     def __init__(self,path,group):
      self.path=path;
      self.group=group;
      self.users=open(self.path).read().split("\n");
    
     def run(self):
      i=0;
      while i < len(self.users)-1:
       print "Removing user " + self.users[i] + " from group " + self.group;
       os.system("dseditgroup -o edit -d " + self.users[i] + " -t user " + self.group);
       i+=1;
    if len(sys.argv) < 3:
     print "Please provide filepath and group to remove from...";
    else:
     session=editor(sys.argv[1],sys.argv[2]);
     session.run();
    print "\n";


    Hope that helps!

    Comment

    Working...