Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jcifs.smb.SmbAuthException: Access Denied

981207May 15 2015 — edited May 15 2015

My problem is when i try to download the file from the particular server path,it is giving me the access denied error.I have granted with access to the server path.

Using jcfs -1.3.18.jar

jcifs.smb.SmbAuthException: Access is denied.

My code is below:

        DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

        DCIteratorBinding dcItteratorBindings = bindings.findIteratorBinding("FileDetailsVOIterator");

        ViewObject voTableData = dcItteratorBindings.getViewObject();

        Row rowSelected = voTableData.getCurrentRow();

     

        NtlmPasswordAuthentication auth;

        SmbFile dir;

        SmbFileInputStream in;

        BufferedInputStream buf;

   

      

        String user  ="Mydomain;shan:shan123";

        String filePath = "smb://" + user + "@ad.com/DocumentManagement/Prod/";

                   

        String dbFileName = rowSelected.getAttribute("FileName").toString();

        String folderName = rowSelected.getAttribute("ReferenceFolder").toString();

                                            

   

        filePath = filePath + folderName + "/" + dbFileName;       

        ExternalContext econtext = facesContext.getExternalContext();

        HttpServletResponse response = (HttpServletResponse)econtext.getResponse();

        response.setContentType("application/force-download");

        String filename = dbFileName;

        try {

           auth = new NtlmPasswordAuthentication(user);

            dir = new SmbFile(filePath,auth);

            buf = new BufferedInputStream(new SmbFileInputStream(dir));   ------->Getting error when try to access the path

                response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");

               

                int stream = 0;

                while ((stream = buf.read()) != -1) {

                    outputStream.write(stream);

                }

                buf.close();

                outputStream.flush();

                outputStream.close();

   

;   

           

        } catch (FileNotFoundException fnfe) {

            fnfe.printStackTrace();

            showMessage(filename + " not found", "ERROR");

        } catch (Exception e) {

            e.printStackTrace();

        }

Kindly help on the same.Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2015
Added on May 15 2015
0 comments
3,104 views