Navigation

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

    Delete user expires

    General pfSense Questions
    1
    3
    1348
    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

      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

        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

          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
          • First post
            Last post

          Products

          • Platform Overview
          • TNSR
          • pfSense Plus
          • Appliances

          Services

          • Training
          • Professional Services

          Support

          • Subscription Plans
          • Contact Support
          • Product Lifecycle
          • Documentation

          News

          • Media Coverage
          • Press
          • Events

          Resources

          • Blog
          • FAQ
          • Find a Partner
          • Resource Library
          • Security Information

          Company

          • About Us
          • Careers
          • Partners
          • Contact Us
          • Legal
          Our Mission

          We provide leading-edge network security at a fair price - regardless of organizational size or network sophistication. We believe that an open-source security model offers disruptive pricing along with the agility required to quickly address emerging threats.

          Subscribe to our Newsletter

          Product information, software announcements, and special offers. See our newsletter archive to sign up for future newsletters and to read past announcements.

          © 2021 Rubicon Communications, LLC | Privacy Policy