Community discussions

MikroTik App
 
alsaidi
just joined
Topic Author
Posts: 2
Joined: Thu Mar 16, 2017 12:49 am

search in user-manager by first-login

Fri Jan 03, 2020 8:00 am

I want to get all users whose first log in date is on a specific day in order to extract a report of the number of users who entered that day .
in API C# i get all session and group by date and get first login .

{
:local found ;
:local NotFound ;
:local first ;
:local Date "dec/28/2015" ;

:foreach session in=[/tool user-manager session find ] do={ 
		:local name [/tool user-manager session get $session  user];		 
		:local fromTime [/tool user-manager session get $session  from-time];
		
		:if ( $fromTime ~ $Date ) do={
			#:put  $name;
			:set $found ($found . "," . "\"" . $name ."\"");
		} else={ 
			:set $NotFound ($NotFound . "," . "\"" . $name ."\"");
			#:put  $name;
			}        
  }  
  :set $found ("(".[:pick $found 1 ([:len $found])].")");   
  :set $NotFound ("(".[:pick $NotFound 1 ([:len $NotFound])].")");   
  #:put  $found;
    
	:local fon [:toarray ($found) ] ;
	:for i from=1 to=([:len $fon]-2) do={

	 :put [:pick $fon $i];

}}

Who is online

Users browsing this forum: No registered users and 70 guests