我正在尝试创建一个脚本以自动授予选择,更新,删除,插入表格给特定用户。
Dim ModelTables, table, tab, newPerm
SET ModelTables = obj.Tables
For Each table in ModelTables
If IsObject(table) Then
Set tab = table
'Testing just on one table
If InStr(tab.Name, "MY_TEST_TABLE")=1 Then
set newPerm = tab.Permissions.createNew()
'-- this is all I managed to create
End If
End if
Next
这就是我设法创建的全部。我不知道许可的结构。我也是VB的新手。有人可以使用提示/正确的代码/文档来支持我吗?
这是一个创建新权限的示例,并列出现有的权限。
option explicit
dim obj
set obj = activemodel
dim ModelTables : set ModelTables = obj.Tables
dim u : set u = Finduser("User_1")
if not u is nothing then
dim table
For Each table in ModelTables
If IsObject(table) Then
dim tab
Set tab = table
dim p
if tab.Permissions.count = 0 then
output "creating permission on " & tab.name
set p = tab.Permissions.createNew
set p.DBIdentifier = u
p.grant = "SELECT,DELETE,INSERT,UPDATE"
end if
' show permissions
output "permissions on " & tab.name
for each p in tab.Permissions
output " for user " & p.DBIdentifier & " : " & p.grant
next
End if
Next
end if
function FindUser(name)
dim u
for each u in activemodel.users
if u.name = name then
set FindUser = u
output "found user"
end if
next
end function