Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

Extracting file in read only mode

I have a PowerBuilder app that uses OLE to ExtractFile which is stored in Lotus Notes.  We would like to put some security on our documents so only the original owner of the document can modify the document and all other users can only open the document in read only mode.  

The code currently looks something like this:
ole_NotesDatabase = ole_NotesSession.GetDatabase ( is_notes_svr, is_notes_filepath)
IF ole_NotesDatabase.IsOpen = True Then
    ole_embeddedobject.ExtractFile ( is_new_file_path  )
end if

Is there a way to open the doc in ready mode only?
0
slim7
Asked:
slim7
  • 4
  • 3
1 Solution
 
ZvonkoSystems architectCommented:
The read mode will not prohibit OLE attachment file extract. It is a document read operation.

0
 
slim7Author Commented:
So do I need to put in logic that if it is the original owner then extractfile, else  openfile in read mode?  If so, how do I open it in read mode?
0
 
marilyngCommented:
Are you askig about the attached file or the Notes Document?  Your posted code is missing a few steps since it doesn't identify the document where the file is attached.

The attached file has the properties the OLE object sets.  Therefore if the attached/detached file had the attributes:  ReadOnly, then it would only be opened in READ mode .. however, file attributes would not deter someone from changing the file attributes.

The answer to your question is that the attached file needs to have security, password, etc., saved with it before you attach it.  Or, you need to use the file available activeX commands to password protect it if the owner isn't the reader after you detach it.   Even if I wanted to do this in Notes, I would first have to detach the file,  set a password using the original program commands, and then reattach it.

Does this help?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
slim7Author Commented:
Well, yes and no...we are trying to avoid passwords to protect the attached file because people forget it and those kind of problems.  So ideally I'd like to check if the user is the original owner and then decide whether to detach the file (so they can edit it) or to open it up so they can only read the file.
0
 
marilyngCommented:
Unfortunately, that can only be done by the program that created the file, and not in Notes.   For instance, I can attach an Excel file, as long as I have read access to the document in Notes, the attachment will show up, and I can detach it, or open it.

In Notes, you can decide if you want to VIEW a file, and so Notes uses the program's file viewer.. i.e. excel viewer, word viewer, to open and VIEW the file in Notes.  If the appropriate exe viewers are available, then you can decide if you're going to shell to the original program or to the viewer program.  

But this won't disable the ability to edit the file.

Now, in Notes, if you detach the file, the original still sits in the Notes Document, same as for Word or Excel, and opening them you usually open temp file, and not the original.   This file they can edit all they like, since the original sits in the Notes Document.

I handle this type of even in PDF files, because that assumes the owner has the original, and if changes need to be made, you just roll up another PDF.  This way I can password protect the PDF, and I don't care if anyone loses the password, because the original is sitting somewhere else.

In fact, I make a point of never remembering the password on the PDF files. :)

0
 
slim7Author Commented:
I haven't looked but command would launch a viewer?  Most of our docs are word, excel or pdf.  Thanks for giving me some direction on how to handle.
0
 
marilyngCommented:
Excel and Word viewers are available at Microsoft.com: http://office.microsoft.com/en-us/officeupdate/CD011347961033.aspx

Now, @urlOpen will open the excel, word or pdf file, but the excel and word files will be editable.  So you can use that to open the pdf file.

Something like this will open an excel file in READ mode only:

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Set uidoc=ws.currentdocument      
      Dim xlFilename As String
      xlFilename= uidoc.FieldGetText("xlFile")
      If Len(xlFilename)<1 Then
            Msgbox "Please enter the filename in the field: xlfile",,"No Filename Specified"
            Exit Sub
      End If
      
      On Error Goto Handle_Error
     'First Connect to Excel and see if there are any records to import......................
      Dim Excel As Variant
      Dim xlWorkbook As Variant
      Dim xlSheet As Variant
      
      Const xlupdateLinks=2
      Dim xlReadOnly As Variant
      xlReadOnly = True
      Print "Connecting to Excel..."
      Set Excel = CreateObject( "Excel.Application" )
      If Excel Is Nothing Then
            Print "Unable to open the excel object..."
            Exit Sub
      End If
      
      Excel.Visible = True
      Excel.Workbooks.Open xlFilename,xlUpdateLinks,xlReadOnly
      Print "Opening " & xlFilename & "..."
      
      Set Excel = Nothing '// Free the memory that we'd used
      
      Exit Sub
      
Handle_Error:      
      If Err = 213 Then
            Msgbox  "Sorry, Excel file: " + xlfilename + " could not be found",,"Unable to Continue"
            Err = 0
            Exit Sub
      End If
      On Error Goto 0
      If Not xlworkbook Is Nothing Then
            Excel.activeworkbook.close         '// Close the Excel file without saving (we made no changes)
            Excel.Quit '// Close Excel
            Set Excel = Nothing '// Free the memory that we'd used
      End If
      Exit Sub
End Sub

---
See here for the excel open method: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl11/html/xlmthOpen1_HV03076845.asp

See here for WORD open methods: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd11/html/womthOpen1_HV03076944.asp
0
 
slim7Author Commented:
Great, thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now