So this is what I want to be able to acomplish.
I have a form where you can give permission to network folders to users in a Active Directory.

I want to be able to make the app revert those permissions based on a date.

I was thinking of adding a console app that will run as a service, but have no idea how the info on which permission to remove it will move from app to app

Store the information in a database (date to remove permisions, folder to change) and run the task (task scheduler) once a day. Look for the current date and change permissions.

Agree with Momerath. Dont use a windows service to constantly poll the time and deicde if action should be taken, this would chew up resouces for the other 23hours 59mins and 58seconds that your not actually doing anything with the permissions etc.

why would you need to control access to shared folders, limiting availablity based on time?

we give permission to specific folder where an specific person can edit some files but have a limited time (a week) to finish the work after that permissions are revoke.

have any example on how to implement the database with the scheduler?

another approach can be create a batch at run time and schedule it ?

sooo how i can approach this ?

You've been given an idea, let's see some code. I don't get paid to write code for you.

wow...!
i know i have been given an idea i already implement the database in my code and all the values like expiration date, username, share folder, etc... but i dont know how to get around this, am not asking for you to write me a code i just ask how to approach this...

i dont have any idea on how to make task schuduler to look for the values in a database and execute all the rows thats have the today date to remove that users permission from the share folder. I though maybe the task scheduler could run a daily script and in the script it will query for the DB values and remove permission accordingly but again am just speculating...

thanks anyway !

this is the code to insert my values to mysql:

                string curso_codigo = textBox4.Text + "_" + textBox5.Text;
                string spath = textBox1.Text;
                string usuario = textBox2.Text;
                string fexpiracion = textBox6.Text;
                string fname = textBox3.Text;
                string proposito = textBox8.Text;
                string funame = textBox3.Text;

                //database connection


                MySqlConnection conn = new MySqlConnection();
                MySqlCommand cmd = new MySqlCommand();

                conn.ConnectionString = "server=localhost;uid=uid;" + "pwd=pwd;database=permdata;";
                if (spath != null)
                {
                    try
                    {
                        conn.Open();
                        cmd.Connection = conn;
                        cmd.CommandText = "INSERT INTO permuser " +
                                      "(user, funame, curso_codigo,proposito, fexpiracion, sfolder) " +
                                  "VALUES " +
                                      "(@user,@funame, @curso_codigo,@proposito, @fexpiracion, @sfolder)";

                        cmd.Parameters.AddWithValue("@user", usuario);
                        cmd.Parameters.AddWithValue("@funame", funame);
                        cmd.Parameters.AddWithValue("@curso_codigo", curso_codigo);
                        cmd.Parameters.AddWithValue("@proposito", proposito);
                        cmd.Parameters.AddWithValue("@fexpiracion", fexpiracion);
                        cmd.Parameters.AddWithValue("@sfolder", spath);


                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Values inserted successfully!",
                        "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                        conn.Close();
                        updateBTN_Click(sender, e);
                        ClearForm();



                    }
                    catch (MySqlException ex)
                    {

                        MessageBox.Show("Can't connect to database\n" + ex.ToString());
                    }

                }
                else
                {
                    MessageBox.Show("values cant be empty");
                }

thanks a lot everyone i end up doing a console app that will be call in schedule task everyday at 5:00pm. in there a foreach loop is matching date = currdate() against the mysql DB and then grab the results usernames and share path and removes permissions for each one then mark each row as expired in a new column.

what I wasnt able to do yet is remove user from the share folder security tab list(see pic)
http://i93.photobucket.com/albums/l66/reavenm/Capture_zps51403cae.png

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.