2

I'm using Active Directory in Windows Server2012 R2 and IIS 8.5 to create a WebDav for each user and it can be accessed via the user-name and user-password. One folder per user. This works perfectly using WebDav clients. I have also a web browser using ithit-ajax-file-browser.

My problem is, when i set parameters to the web-part the server shows up an authentification pop-up before logging me automatically.

I'im using

    var settings = {
                    BasePath: '/davbrowser/',                      
                    Id: 'AjaxFileBrowserContainer',     
                    Url: webDavServerPath,              
                    Style: 'height: 100%; width: 100%', 
                    MsOfficeTemplatesPath: '/templates/', 
                    SelectedFolder: webDavServerPath,   
                    ThemeName: 'windows_8',             
                    IconsSize: 16                       
                    //Platform: 'mobile'                
                };
var ajaxFileBrowser = new ITHit.WebDAV.Client.AjaxFileBrowser.Controller(settings);
ajaxFileBrowser.GetSession().SetCredentials('username', 'password');
ajaxFileBrowser.SetSelectedFolder('/username');

`

The auto-login works but the login pop-up still appears. Are there any solution to delete it? I'm using basic authentification

Kassav'
  • 1,130
  • 9
  • 29

2 Answers2

3

SOLUTION

I'm using basic authentification and i need to send username and password in the headers. I can't use this form. username:password@fileserver/userfolder This method works only on firefox. It's an issue here chromium issue So the solution is to use XMLHttpRequest.

webDavServerPath = 'fileserver/userfolder';
var xml = new XMLHttpRequest(); 
xml.open('GET',webDavServerPath,false,username,password)
xml.send('');

This works fine in most browser and must be used under SSL.

Kassav'
  • 1,130
  • 9
  • 29
1

In your code, in settings, you are setting the SelectedFolder parameter. This causes the request to be sent before the SetCredentials is called. Remove the SelectedFolder setting and call only SetSelectedFolder, which is doing the same thing, but after the SetCredentials call.

I would also suggest to update your code to use the async approach, introduced in IT Hit Ajax File Browser v2.1.0.1483:

var settings = {
                BasePath: '/davbrowser/',                      
                Id: 'AjaxFileBrowserContainer',     
                Url: webDavServerPath,              
                Style: 'height: 100%; width: 100%', 
                MsOfficeTemplatesPath: '/templates/', 
                //SelectedFolder: webDavServerPath,   
                ThemeName: 'windows_8',             
                IconsSize: 16                       
                //Platform: 'mobile'                
            };


    var ajaxFileBrowserLoader = new ITHit.WebDAV.Client.AjaxFileBrowserLoader(settings);
    ajaxFileBrowserLoader.oninit = function(ajaxFileBrowser) {
        // This event is fired when control is loaded and created.
        ajaxFileBrowser.GetSession().SetCredentials('username', 'password');
        ajaxFileBrowser.SetSelectedFolder('/username'); 
    };
    ajaxFileBrowserLoader.LoadAsync();

Another thing, that can cause the standard web browser login dialog is the CORS request. That is in case your settings.Url parameter contains WebDAV server URL that is located in another origin (domain, port or protocol). Unfortunately there is no any real solution for this case. The only workaround would be placing the page with Ajax File Browser on the same server where WebDAV server is located. You can find more info about it here.

IT Hit WebDAV
  • 5,652
  • 12
  • 61
  • 98
  • This did not solve my problem. Are there any architecture issue concerning IIS authentification type or Webdav Authoring rules or may be application pool? Are there any tutorial that can help – Kassav' Oct 29 '14 at 10:09
  • Are you using cross-domain access? This can also cause the standard web browser dialog popup. I have added the paragraph about CORS. – IT Hit WebDAV Oct 29 '14 at 20:39
  • I think that the problem is WebDavServerPath=https://FileServer/. For each user, the appropriate DavFolder is located on https://FileServer/username. Note that the folder name is the same as the user name. In the Autorizing Rules in IIS i allow only domain users. Are there any clarification in this case. – Kassav' Oct 30 '14 at 12:08
  • SOLUTION I'm using basic authentification and i need to send username and password in the headers.I can't use this form. https://username:password@fileserver/userfolder This method works only on firefox. It's an issue here [chromium issue][1] [1]: https://code.google.com/p/chromium/issues/detail?id=123150 So the solution is to use XMLHttpRequest. webDavServerPath = 'https://fileserver/userfolder'; var xml = new XMLHttpRequest(); xml.open('GET',webDavServerPath,false,username,password) xml.send(''); This works fine in most browser and must be used under SSL. – Kassav' Nov 04 '14 at 12:20