VBA管理filezilla 之用户组及共享目录权限批量代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VBA管理filezilla 之用户组及共享目录权限批量代码相关的知识,希望对你有一定的参考价值。

VBA管理filezilla 之用户组及共享目录权限批量代码
技术图片
表格数据

VBA模块代码:


Option Explicit
Dim str, xmlfile As String
Dim i As Integer

Sub xiegroups()
Dim GROUPS
Set GROUPS = Sheets("GROUPS")

‘用户组信息开始写入
str = " <Groups>"
Call xiexml(str)

For i = 2 To GROUPS.Range("A65535").End(xlUp).Row
‘判断如果是用户组的第一行

If GROUPS.Range("B" & i) = 1 Then
str = " <Group Name=" & Chr(34) & GROUPS.Range("A" & i) & Chr(34) & ">"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "Bypass server userlimit" & Chr(34) & ">0</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "User Limit" & Chr(34) & ">0</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "IP Limit" & Chr(34) & ">0</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "Enabled" & Chr(34) & ">1</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "Comments" & Chr(34) & ">" & GROUPS.Range("C" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "ForceSsl" & Chr(34) & ">0</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "8plus3" & Chr(34) & ">0</Option>"
Call xiexml(str)
str = " <IpFilter>"
Call xiexml(str)
str = " <Disallowed />"
Call xiexml(str)
str = " <Allowed />"
Call xiexml(str)
str = " </IpFilter>"
Call xiexml(str)
str = " <Permissions>"
Call xiexml(str)
End If

‘目录及权限设置

str = " <Permission Dir=" & Chr(34) & GROUPS.Range("D" & i) & Chr(34) & ">"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "FileRead" & Chr(34) & ">" & GROUPS.Range("E" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "FileWrite" & Chr(34) & ">" & GROUPS.Range("F" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "FileDelete" & Chr(34) & ">" & GROUPS.Range("G" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "FileAppend" & Chr(34) & ">" & GROUPS.Range("H" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "DirCreate" & Chr(34) & ">" & GROUPS.Range("I" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "DirDelete" & Chr(34) & ">" & GROUPS.Range("J" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "DirList" & Chr(34) & ">" & GROUPS.Range("K" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "DirSubdirs" & Chr(34) & ">" & GROUPS.Range("L" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "IsHome" & Chr(34) & ">" & GROUPS.Range("M" & i) & "</Option>"
Call xiexml(str)
str = " <Option Name=" & Chr(34) & "AutoCreate" & Chr(34) & ">" & GROUPS.Range("N" & i) & "</Option>"
Call xiexml(str)
str = " </Permission>"
Call xiexml(str)
‘判断是否用户组的最后一行

If GROUPS.Range("B" & i) = Application.WorksheetFunction.CountIf(GROUPS.Range("A:A"), GROUPS.Range("A" & i)) Then
str = " </Permissions>"
Call xiexml(str)
str = " <SpeedLimits DlType=" & Chr(34) & "1" & Chr(34) & " DlLimit=" & Chr(34) & "10" & Chr(34) & " ServerDlLimitBypass=" & Chr(34) & "0" & Chr(34) & " UlType=" & Chr(34) & "1" & Chr(34) & " UlLimit=" & Chr(34) & "10" & Chr(34) & " ServerUlLimitBypass=" & Chr(34) & "0" & Chr(34) & ">"
Call xiexml(str)
str = " <Download />"
Call xiexml(str)
str = " <Upload />"
Call xiexml(str)
str = " </SpeedLimits>"
Call xiexml(str)
str = " </Group>"
Call xiexml(str)
End If
Next

‘用户组信息写入结束
str = " </Groups>"
Call xiexml(str)

End Sub

Sub xiexml(AnyString)
xmlfile = "G:11filezilla.xml"
Open xmlfile For Append As #1
Print #1, str
Close #1
End Sub

输出效果
技术图片
技术图片

以上是关于VBA管理filezilla 之用户组及共享目录权限批量代码的主要内容,如果未能解决你的问题,请参考以下文章

Linux系统之文件共享目录设置方法

搭建nfs共享存储服务之二nfs服务端配置语法及配置实战详解

Azure虚拟机上配置FTP服务器FileZilla

用户管理及用户提权

Jetson Xavier NX (13) -- 远程文件传输

Jetson Xavier NX (13) -- 远程文件传输