Koozali.org: home of the SME Server

adding/removing a user to group by cron task

Offline axessit

  • *****
  • 213
  • +0/-0
adding/removing a user to group by cron task
« on: March 05, 2009, 10:38:02 AM »
I need to add a user (via cron task) to add a user to a group, then subsequently remove them. I am using it to add a user via time. I have a cron job set up and working that adds them via command line, but that's obvoiusly bypassing things and I need to do it via the accounts database.

At the moment I use
Code: [Select]
usermod -G shared,library,banned mikeso that mike gets put in the banned group as well as has access to his home folder and the library ibay. Then later on I use
Code: [Select]
usermod -G shared,library miketo take him out of the group.

The banned group does not have internet access. Thus (as I am using PAM authentication) I need to use the accounts properties somehow. When I use
Code: [Select]
db accounts show mike I don't see mikes group membership.

How should I be doing this ?

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: adding/removing a user to group by cron task
« Reply #1 on: March 05, 2009, 10:57:44 AM »
Try this:

Code: [Select]
db accounts setprop mygroup Members user1,user2,user3
signal-event group-modify mygroup

Offline axessit

  • *****
  • 213
  • +0/-0
Re: adding/removing a user to group by cron task
« Reply #2 on: March 05, 2009, 12:49:21 PM »
Thanks very much. Works a treat!

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: adding/removing a user to group by cron task
« Reply #3 on: March 06, 2009, 03:55:04 AM »
axessit

If you are not familiar with sme server specific commands (ie signal events), then you can make changes in server manager eg add a user, change their group or anything else etc etc, and then review the messages log file.
You will see what commands get issued by sme server to make those changes, and then just use those commands in your cron jobs/scripts etc.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: adding/removing a user to group by cron task
« Reply #4 on: March 06, 2009, 04:31:14 AM »
I need to add a user (via cron task) to add a user to a group, then subsequently remove them.

That sounds a very unusual thing to do.

What problem are you trying to solve?

Offline axessit

  • *****
  • 213
  • +0/-0
Re: adding/removing a user to group by cron task
« Reply #5 on: March 06, 2009, 04:44:09 AM »
Kids internet usage - my kids can log onto the computer but can't access the internet unless Mum or Dad put in their password :grin:, but the older son can access after the smaller ones go to bed without me having to be there to do it. Unfortunately he plays games after school instead of homework, or his siblings jump on the computer if he puts in his password etc. Since they can't keep their passwords secret. But the computer is there to type up stuff.

Plus, I can now deploy it to schools so that they can't access the internet during breaks and lunch times (as they all know the internet passwords).

Forced network policies - childs play :lol:

Offline axessit

  • *****
  • 213
  • +0/-0
Re: adding/removing a user to group by cron task
« Reply #6 on: March 06, 2009, 04:48:01 AM »
I suppose i should add for the viewing audience, there are actually two cron jobs. 1st to put him in the banned group at say 9am, then another to take him out, at say 8pm.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: adding/removing a user to group by cron task
« Reply #7 on: March 06, 2009, 07:35:26 AM »
as far as I understand, OP want to give to his users internet access only in limited time periods...

I think that a squid acl wolud be better..

my 2c
Stefano

Offline David Harper

  • *
  • 653
  • +0/-0
  • Watch this space
    • Workgroup Technology Solutions
Re: adding/removing a user to group by cron task
« Reply #8 on: March 06, 2009, 07:44:24 AM »
Now I'm curious. How would the OP create an appropriate Squid ACL?

Offline stephen noble

  • *
  • 607
  • +1/-0
    • Dungog
Re: adding/removing a user to group by cron task
« Reply #9 on: March 06, 2009, 08:23:16 AM »
If your using dansguardian, squid accepts requests from localhost so can't determine the user.


Offline axessit

  • *****
  • 213
  • +0/-0
Re: adding/removing a user to group by cron task
« Reply #10 on: March 06, 2009, 08:46:00 PM »
Yes, I am using dansguardian for content filtering and also PAM authentication to internet access, so it serves me well, since all I need do is put the users into a group that is banned (or alternatively ban all users except those in an allowed group). I guess it would depend on how dansguardian interacts with squid - that being said, I enjoy using a bypass so I don't need any password out in my "kids free zone" office.