问题描述
我想将系统用户列表与我的员工目录绑定,以便我可以存储其他用户信息并基于当前用户创建 RLS 访问限制。
所以,我在员工目录中创建了 ID 属性,并在 ItemForm 模块中编写了这段代码:
&AtClient
Procedure IDStartChoice(Item,ChoiceData,StandardProcessing)
// Fill out the list of system users to choose from
StandardProcessing = False;
ChoiceData = GetUserList();
EndProcedure
&AtClient
Procedure IDChoiceProcessing(Item,SelectedValue,StandardProcessing)
// Fill out Users catalog item data
StandardProcessing = False;
ThisForm.Object.ID = SelectedValue;
Object.ID = GetIDUser(SelectedValue);
EndProcedure
&AtServerNoContext
// Read the list of system users
Function GetUserList()
UserList = New ValueList;
UserArray = InfobaseUsers.GetUsers();
For Each SystemUser In UserArray do
UserList.Add(SystemUser.UUID,SystemUser.FullName);
EndDo;
Return UserList;
EndFunction
&AtServerNoContext
Function GetIDUser(UserID)
If ValueIsFilled(UserID) then
SetPrivilegedMode(True);
Return InfobaseUsers.FindByUUID(UserID).FullName;
EndIf;
EndFunction
这里的想法是这行代码 Object.ID = GetIDUser(SelectedValue);
读取当前系统用户 ID 并将其存储到目录中。
我还创建了 CurrentUser 会话参数并将其值设置为属于会话模块中当前系统用户的 CatalogRef.Employees,如下所示:
Procedure SessionParameteRSSetting(requiredParameters)
// Set the CurrentUser session parameter value
SetPrivilegedMode(True);
CurrentUser = InfobaseUsers.CurrentUser();
SessionParameters.CurrentUser = Catalogs.Employees.FindByAttribute("ID",CurrentUser.UUID);
EndProcedure
我将这个 Read RLS 限制添加到 Emlopoyees 目录:WHERE Ref = &CurrentUser
,但是当我在任何特定用户下打开它时,我仍然可以看到所有用户(未过滤):
Should see Mesut only,not all the users
请帮忙!
Here is the DT file with the app
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)