码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2019-03-10 13:47:08      阅读:426      评论:0      收藏:0      [点我收藏+]

标签:close   UNC   http   代码   sha   lis   row   -o   png   

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:\11\filezilla.xml"
Open xmlfile For Append As #1
Print #1, str
Close #1
End Sub

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

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

标签:close   UNC   http   代码   sha   lis   row   -o   png   

原文地址:https://blog.51cto.com/mflag/2360740

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!