简体   繁体   English

如何检查某个用户是否具有读者对文档的访问权限

[英]How to check if a certain user has reader-access to a document

For an xpage-application with java beans i need to check if a certain user(not current user) has reader-access to a document. 对于使用Java Bean的xpage应用程序,我需要检查某个用户(不是当前用户)是否具有读者对文档的访问权限。 All acceslevels above (Database ACL, XPage ACL...) can be taken for granted. 上面的所有访问级别(数据库ACL,XPage ACL ...)都可以视为理所当然。 Current User is always at least author. 当前用户始终至少是作者。

Each document has one readerfield "readers" and three authorfields "creator","authors","AdminAuthor", last can be ignored,since it always only contains "[Admin]" for every document 每个文档都有一个读者字段“ readers”和三个authorfields“ creator”,“ authors”,“ AdminAuthor”,由于每个文档始终只包含“ [Admin]”,因此最后一个可以忽略

Current idea is to get the groups of the user like showed here( Determine all groups for a defined user ), loop through them and compare to the reader and author fields field content 当前的想法是获得此处显示的用户组( 确定已定义用户的所有组 ),循环遍历并与“读者”和“作者”字段进行比较

Why i don't like it: 为什么我不喜欢它:

  • use of an undocumented API 使用未记录的API
  • horrible performance 糟糕的表现

Is there any better way to do so? 有什么更好的办法吗? Especially with nested groups in mind, so $ServerAccess view is not really an option. 尤其是考虑到嵌套组,因此$ ServerAccess视图并不是真正的选择。

Current code: 当前代码:

 public boolean isReader(String notesName, String documentID){
    try {
        Vector<String> readers= getAllReaderFieldsValues(documentID);
        if(readers.contains(notesName)){
            return true;
        }
        lotus.notes.addins.DominoServer server = new lotus.notes.addins.DominoServer(DominoUtils.getCurrentSession().getServerName());
        for(String group:(Vector<String>)server.getNamesList(notesName)){
            if (readers.contains(group)){
                return true;
            }
        }
    } catch (NotesException e) {
        //ErrorHandling
    }
    return false;
}

Thanks for any help 谢谢你的帮助

There are different ways to check if a user has access to a document, but all of these are undocumented (but still useable since a decade), so they won't fit your requirements (ie running in a different user context or a special view with a "$C1$" column, ...) 有多种检查用户是否有权访问文档的方法,但是所有这些方法都没有文档记录(但十年以来仍然可用),因此它们不符合您的要求(即在不同的用户上下文或特殊视图中运行)带有“ $ C1 $”列,...)

A "documented" way to do what you want is just to add a user to a reader field, if his name is not already in the list. 如果您的名字不在列表中,则将其添加到阅读器字段中是一种“已记录”的操作方式,它只是将用户添加到阅读器字段中。 There is no need to check if the user has access or not. 无需检查用户是否具有访问权限。

I still wondering about your scenario, because I don't understand what you are trying to realize: You are checking if a user is in a specific group which gives him access to a document. 我仍然想知道您的情况,因为我不明白您要实现的目的:您正在检查用户是否在特定的组中,该组可以授予他对文档的访问权限。 If the user is in one of these groups, you skip his name. 如果用户属于这些组之一,则跳过其名称。 In the meantime, the user is removed from the group, and has no longer access to the document... 同时,该用户已从该组中删除,并且无法再访问该文档...

Why not working with groups or roles? 为什么不使用组或角色? No coding, just administration. 没有编码,只有管理。 Are you fixing organizational problems? 您是否正在解决组织问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查用户是否具有对Java中数据库的写访问权 - how to check if user has write access to a database in java 如何获取特定用户是否在根节点上具有{写入,读取}权限 - How to get check if a certain user has {Write, read} permissions on a root node 如何检查文件中是否包含用户输入的特定数字? (Java)的 - How can I check if a file contains a certain number that the user has input? (java) 如何检查我的Firebase数据库是否具有特定用户的数据? (Android / Java) - How can I check if my Firebase database has data for a certain user? (Android/Java) 检查当前用户有权访问数据库 - check current user has access to database 如何检查是否已调用某种方法? - How to check if a certain method has been called? 如何使用jsp视图检查某个用户是否已创建数据库项 - How to check if certain user has made database items using jsp view Spring安全检查用户是否可以访问提到的url - Spring security check if user has access to mentioned url 如何检查登录 Firebase 用户是否有密码 - How to check if signed in Firebase user has a Password 如何检查是否已在数据库中插入具有某些值的特定行 - How to check if a specific row with certain values has been inserted in the Database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM