Generating a List of Expired User Accounts and Expiration Dates

EFT Server Administrators may need to retrieve a list of expired user accounts and view the expiration date of user accounts. This functionality is not yet available in EFT Server or the Auditing and Reporting module. However, there are commands in the COM interface that can provide this information.

For details of using COM, refer to GlobalSCAPE Server COM API. The details of how to get a list of expired accounts is below.

Below is an example for advanced users who can use the example as a guide to creating their own scripts. If you need assistance with creating custom scripts, please contact GlobalSCAPE Professional Services.

Determining the Expiration Date for a User Account (GetExpirationDate)

Use the ICIClientSettings interface GetExpirationDate method to determine the expiration date for a particular user account; set it with SetExpirationDate.

Signature:

HRESULT GetExpirationdate (

[out] VARIANT *dDate,

[out, retval] VARIANT_BOOL *pVal);

dDate results in a string value, i.e. "4/29/05"

Example:

Dim strUser: strUser = "test"

set oUserSettings = oSite.GetUserSettings(strUser)

dtAccExpDate =  oUserSettings.GetExpirationDateAsVariant()

WScript.Echo ("dtAccExpDate = "  & dtAccExpDate)

 

 In many non-windows environments, "KMarsh" and "kmarsh" are two different usernames, and case matters. GetUserSettings is case insensitive (in versions 5.2.5 and later). That is, with this method, "KMarsh", "KMARSH", and "kmarsh" are all the same user account.

Example Script

The example VB script provided below retrieves user accounts and expiration dates and writes them to a Microsoft Excel spreadsheet. (Of course, Excel must be installed on the computer on which you are running the script.)

To use the script

  1. Copy the script below into a VB script editor.

  2. In the section that contains EFT Server address and administrative login, provide your Server address and port and the administrator username and password.

  3. 'Get Server address and administrative login

       txtServer = "localhost"

       txtPort =  "1100"

       txtUserName = "root"

       txtPassword = "root"

  4. Execute the .vbs file.

-----------------------------------------------------------START-------------------------------------------------------------------------------

' Declare variables Dim CRLF Dim EFTServer Dim Sites, Site, aUsers 'Create the COM Object Set EFTServer = CreateObject("SFTPCOMInterface.CIServer") CRLF = (Chr(13)& Chr(10)) 'Get Server address and administrative login    txtServer = "localhost"    txtPort =  "1100"    txtUserName = "root"    txtPassword = "root" 'Connect to Server On Error Resume Next EFTServer.Connect txtServer, txtPort, txtUserName, txtPassword If Err.Number  0 Then    MsgBox "Error connecting to '" & txtServer & ":" & txtPort & "' -- " & err.Description & " [" & CStr(err.Number) & "]", vbInformation, "Error"    WScript.Quite(255) End If set Sites=EFTServer.Sites 'Set Site to first ftp site in list on server set Site=Sites.Item(0) Dim objexcel Set objExcel = createobject("Excel.application") objexcel.Visible = True objexcel.Workbooks.add     arUsers = Site.GetUsers()  For j = LBound(arUsers) to UBound(arUsers) 'Name in first column objExcel.Cells(j+1, 1).Value = arUsers(j)   Set oUserSettings = site.GetUserSettings(arUsers(j)) 'boolAccExp = oUserSettings.GetExpirationDate dtAccExpDate =  oUserSettings.GetExpirationDateAsVariant() If (dtAccExpDate = "12:00:00 AM") Then objexcel.Cells(j+1, 2).Value = "not set to expire" Else objexcel.Cells(j+1, 2).Value = dtAccExpDate End If objexcel.Columns("A:A").EntireColumn.Autofit objexcel.Columns("A:B").EntireColumn.Autofit  Next        'Close COM connection EFTServer.Close ' Release interfaces set oSettings = nothing set Site = nothing set Sites = nothing set EFTServer = nothing WScript.Quit(0)

--------------------------------------END----------------------------------------------

Related Topics (in the GlobalSCAPE Server COM API User Guide)

Setting the Expiration Date for a User Account (SetExpirationDate)

Retrieving a User's Description (GetDescription)

Client Settings Interface Methods