Search code examples
xpages-ssjs

get data from database the user has no access to


I try to get just 1 item out of a database to which the current user doesn't has access to

I tried :

var db:NotesDatabase = sessionAsSigner.getDatabase("","somedir/somedatabase.nsf");
var somedata= (@Unique(@DbLookup(db,"viewname","searchkey",2)));

this only seems to work when the user does have access. What is the best way of dooing this ?


Solution

  • I think your problem is the use of @DBLookup because the first parameter of @DBLookup must be a string and not an object of type NotesDatabase!

    Instead of @DBLookup try this, it should work:

    var db:NotesDatabase = sessionAsSigner.getDatabase("","somedir/somedatabase.nsf");
    var notesView:NotesView = db.getView(viewname);
    var dc:NotesDocumentCollection = notesView.getAllDocumentsByKey(searchkey, true);
    

    I hope this helps :)