I have a FileZilla FTPS server with several hundred accounts. Each time I create an account, I assign a group membership based on the month the account was created (i.e. "2016-01" for all accounts created in January of 2016).
It has been a couple years since I began this practice, and I now have about 3 dozen groups of users dating back to 2013. My original goal was to write a purging script that would go through and remove all user accounts from the XML config file that matched a particular group name, and run that to get rid of accounts more than 60 days old. I haven't done that, because my XML-fu is simply not strong enough.
I'd really like to see an enhancement to FileZilla Server that allows for batch deletion of users based on either group membership, or date of user creation.
Feature Request: Delete all Users based on Group Membership or Create Date
Moderator: Project members
Re: Feature Request: Delete all Users based on Group Membership or Create Date
I like this idea. It's something I'll keep in mind for the upcoming FileZilla Server rewrite.
Re: Feature Request: Delete all Users based on Group Membership or Create Date
@botg: The server I use has such a feature, where you can limit an account by using an expiry date or maximum age. Then the account is deactivated (or deleted if desired).
No support requests over PM! You will NOT get any reply!!!
FTP connection problems? Please read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
FileZilla Pro support: https://customerforum.fileZilla-project.org
FTP connection problems? Please read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
FileZilla Pro support: https://customerforum.fileZilla-project.org
Re: Feature Request: Delete all Users based on Group Membership or Create Date
From time to time I need to create temporary user accounts on my server, those accounts must be disabled/deleted after the expiration date. To achieve this in an automatic way, I set the expiration date on the 'Comments' field and run the following vbscript on a daily scheduled task. It should be quite easy to adapt it to suit your needs.
Code: Select all
'******************************************************************************
'
' Purpose: disable or delete 'FileZilla Server' expired user accounts. The
' expiration date is determined by the presence of the
' 'ACCOUNT_EXPIRATION_STRING' string on the 'Comments' field (case
' sensitive) followed by the expiration date.
' Accounts are deleted if the expiration date is less than current
' date minus 'DAYS_BEFORE_DELETING_USER_ACCOUNT' number of days, they
' are disabled if the expiration date is less than or equal to current
' date.
' To take changes into account, the server is forced to reload the
' configuration, therefore it does not need to be restarted.
'
' Returns: 0 (zero) on success, the error number on failure.
'
' Requirements: none. Uses MSXML6 which is shipped with Windows.
'
' Assumptions: the account running the script has read/write permissions on
' 'SERVER_CONFIG_FILE_PATH' and can run shell commands.
'
'******************************************************************************
Option Explicit
Const SERVER_CONFIG_FILE_PATH = "C:\Program Files\FileZilla Server\FileZilla Server.xml"
Const SERVER_EXECUTABLE_FILE_PATH = "C:\Program Files\FileZilla Server\FileZilla Server.exe"
Const ACCOUNT_EXPIRATION_STRING = "Expires on"
Const DAYS_BEFORE_DELETING_USER_ACCOUNT = 30
Dim objXMLDocument
Set objXMLDocument = CreateObject("Msxml2.DOMDocument.6.0")
objXMLDocument.async = False
objXMLDocument.load(SERVER_CONFIG_FILE_PATH)
If objXMLDocument.parseError.errorCode <> 0 Then
WScript.Quit objXMLDocument.parseError.errorCode
Else
Dim objUsers
Dim objUser
Dim strUserComments
Dim strExpirationDate
Dim strSettingsFileModified
Dim intReturnValue
Set objUsers = objXMLDocument.selectNodes("/FileZillaServer/Users/User[contains(Option[@Name='Comments'], '" & ACCOUNT_EXPIRATION_STRING & "')]")
For Each objUser In objUsers
strUserComments = objUser.selectNodes("Option[@Name='Comments']").item(0).text
strExpirationDate = Mid(strUserComments, InStr(strUserComments, ACCOUNT_EXPIRATION_STRING) + Len(ACCOUNT_EXPIRATION_STRING) + 1, 10)
If IsDate(strExpirationDate) Then
If Date > DateAdd("d", DAYS_BEFORE_DELETING_USER_ACCOUNT, CDate(strExpirationDate)) Then
'delete user node
objUser.parentNode.removeChild(objUser)
strSettingsFileModified = "True"
ElseIf Date >= CDate(strExpirationDate) And objUser.selectNodes("Option[@Name='Enabled']").item(0).text <> "0" Then
'disable user account
objUser.selectNodes("Option[@Name='Enabled']").item(0).text = "0"
strSettingsFileModified = "True"
End If
End If
Next
If strSettingsFileModified = "True" Then
Dim objShell
objXMLDocument.save(SERVER_CONFIG_FILE_PATH)
Set objShell = CreateObject("WScript.Shell")
intReturnValue = objShell.Run("""" & SERVER_EXECUTABLE_FILE_PATH & """" & " /reload-config")
End If
WScript.Quit intReturnValue
End If