• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Delete user expires

Scheduled Pinned Locked Moved General pfSense Questions
3 Posts 1 Posters 1.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Airy
    last edited by Jun 18, 2012, 12:50 PM Jun 18, 2012, 11:35 AM

    Hi every one,

    I'am installing a pfsense server and I need you help for something :
    when you add a new user, you can choose to add an expiration date. When the date is over, the user can't connect but he is still in the config.xml file and so in the webGUI.
    I'm trying to delete all them.
    Here is the php code I use to find the user name, his ID and teh expiration date

    
    function parse_user_date (){
    	//open config.xml file
    	$today = date("m/d/y");
    	$xml = new XMLReader();
    	if (!$xml->open('/cf/conf/config.xml')) {
    		die("Impossible de charger le fichier XML");
                    echo "error
    ";
    	}
    	while($xml->read()){
    	//recuperation of informations
                if ($xml->nodeType == XMLREADER::ELEMENT and $xml->localName == "scope"){
    				if($xml->read()){
    					if($xml->value == "user"){
    						$debug=0;
    						while($debug<20){
    							if($xml->nodeType == XMLREADER::ELEMENT and $xml->localName == "name"){
    								if($xml->read()){
    									$user=$xml->value;
    									$debug=20;
    									$debug2=0;				
    									while($debug2<20){
    										if($xml->nodeType == XMLREADER::ELEMENT and $xml->localName == "expires"){
    											if($xml->read()){
    												$date=$xml->value;
    												$debug2=20;
    												if(strlen($date)>8 and $today>$date){
    													$debug3=0;
    													$uid=0;
    													while($debug3<20){
    														if($xml->nodeType == XMLREADER::ELEMENT and $xml->localName == "uid"){
    															if($xml->read()){
    																$uid=$xml->value;
    																echo $user ." : ".$uid." -> ".$date ."
    ";
    																/***************Integ*******************************/
                                                                                                                                    /***Here is the fonction I found in system-usermanager.php*****/
    																local_user_del("test_time");
    																//$userdeleted = $a_user[$id]['name'];
    																//unset($a_user[$id]);
    																write_config();
    																/***********************************************/
    															}
    														}
    														else{
    														$xml->read();
    														$debug3++;
    														}
    													}												
    												}
    											}
    										}
    										else{
    										$xml->read();
    										$debug2++;
    										}
    									}
    								}
    							}
    							else{
    								$xml->read();
    							}
    							$debug++;	
    						}
    					}    
    				}
    			}
    	}
    }
    
    

    I wan't to use the local_user_del() function in pfsense (function found in system-usermanager.php). I tried to put in arguments, the UserID or his name, but he's not deleted.

    Can you help me please ?
    Airy

    1 Reply Last reply Reply Quote 0
    • A
      Airy
      last edited by Jun 19, 2012, 7:12 AM

      Hi,

      I'd like to add some new elements :
      when I manually delete an user in the config.xml, he don't disapear in the system-usermanager.php webGUI.
      The unset command delete the user in config.xml.
      But I still don't know how local_user_del() works.

      Airy

      1 Reply Last reply Reply Quote 0
      • A
        Airy
        last edited by Jun 21, 2012, 1:40 PM

        I'm still having trouble with this and I do not have the answer.
        Does someone know or can tell me in which way seeking ?

        Airy

        1 Reply Last reply Reply Quote 0
        3 out of 3
        • First post
          3/3
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
          This community forum collects and processes your personal information.
          consent.not_received