none
Problem with dynamic menu/table which populates sharepoint sites/sub-sites and pages - with SPAPI JavaScripts

    Question

  • Hello,

    I have used SPAPI_Core.js, SPAPI_Lists.js, SPAPI_Webs.js and a Web.html to create a dynamic table which populates all the sites/Sub-sites and Pages which are there in the main site. I am mapping Web.html in a master pages Content Editor Webpart.
    its working fine and good when i login into the portal with Designer access.
    But with reader access i am observing that it is throughing an error message "You are : Unauthorized" after taking user name and password.
    And finally in the main page where i have added the web part it is displaying "Unavailable".
    Any idea why it is bevaing in this way. Please help.....

    Thanks and regards
    KBSK
    Wednesday, January 6, 2010 11:49 AM

Answers


  • Not the SharePoint permission, but the physical file and folder's permission. Make sure it is the same as the layout.
    To set the permissions for a file or folder:
    1. Use Windows Explorer to locate the file or folder for which you want to edit the permissions.
    2. Right-click the folder, and then click Properties .
    3. Click the Security tab.
    4. To add a new access control setting to the folder, click Add .
    5. Select the users, computers, or groups that this access control setting is applied to, click Add , and then click OK .
    6. To remove an access control setting, click Remove .
    7. To edit the permissions for any group, select the user or group, and then use the corresponding check boxes in the Permissions pane.
    8. Click OK to accept the settings, click Cancel to cancel any changes you have made, or click Apply to apply the changes without closing the file or folder properties.

    Cogito, ergo sum. How liberating it would be to live a life free of all the inane courteous formalities which are utterly meaningless, insincere and therefore degrading!
    Monday, January 11, 2010 2:32 AM
  • If you store the js in document library, that means the anonymous users, who do not have any permission on the library, cannot get the js files.
    You need to place them in a physical location and perform the above steps. 

    Cogito, ergo sum.
    Monday, January 11, 2010 5:08 AM

All replies

  • Where did you put your JS files?

    You need to put'em in "layouts" and make the security attributes the same as the default Core.js.
    Cogito, ergo sum. How liberating it would be to live a life free of all the inane courteous formalities which are utterly meaningless, insincere and therefore degrading!
    Friday, January 8, 2010 1:18 AM
  • Hi,

    I have uploaded JavaScript and Html files into a Script folder (Which i have created) of the sharepoint site. And i am maping the htm file to a Content Editor Webpart of the default.aspx where i need to display the content (Sites/Sub-Sites/Pages in the form of a table / menu)
    I have also observed that the error is throwne by SPAPI_Webs.js where my html is creating Lists. please have a look at the part of the code where it is creating a new instance of Lists.

    Also how to make the security attributes the same... please explain...

    .......
    var site=document.getElementById("ctl00_PlaceHolderSiteName_onetidProjectPropertyTitle").href;

    function getWebs() {
    alert('into getWebs');

     var lists = new SPAPI_Webs(site);
     var items = lists.getWebCollection();
    ..........

    please do let me know for further info.


    Thnx
    Friday, January 8, 2010 5:17 AM
  • Make sure the security attributes of the script folder and the js inside are consistent with "layouts" folder.
    Cogito, ergo sum. How liberating it would be to live a life free of all the inane courteous formalities which are utterly meaningless, insincere and therefore degrading!
    Friday, January 8, 2010 6:09 AM
  • Hi,
    Many thanks for your replys :)

    But what i have observed is that when i change the permission level of the other user in sharepoint site to "Contribute" then the user can able to see the Table/Menu with out any errors.
    But when i change the permission level to "Read" then the user is asked for Login username and password for 3 times and then an error message is shown "You are not : Authorized"

    Any suggestions please....

    Thanx
    Friday, January 8, 2010 1:18 PM

  • Not the SharePoint permission, but the physical file and folder's permission. Make sure it is the same as the layout.
    To set the permissions for a file or folder:
    1. Use Windows Explorer to locate the file or folder for which you want to edit the permissions.
    2. Right-click the folder, and then click Properties .
    3. Click the Security tab.
    4. To add a new access control setting to the folder, click Add .
    5. Select the users, computers, or groups that this access control setting is applied to, click Add , and then click OK .
    6. To remove an access control setting, click Remove .
    7. To edit the permissions for any group, select the user or group, and then use the corresponding check boxes in the Permissions pane.
    8. Click OK to accept the settings, click Cancel to cancel any changes you have made, or click Apply to apply the changes without closing the file or folder properties.

    Cogito, ergo sum. How liberating it would be to live a life free of all the inane courteous formalities which are utterly meaningless, insincere and therefore degrading!
    Monday, January 11, 2010 2:32 AM
  • Hello,

    Right now my JavaScript files in Sharepoint portal, i have created a saperate Document library folder named "Scripts" in which i have placed the JS files. So do you mean to say that I need to reload the JS files applying the above mentioned changes.

    Also, I have observed one more thing - If I give a user with "Contributor" or above permission level in Sharepoint protal then he is not getting any errors.
    User is getting 401 error only when he is having "Reader" or below reader access to the sharepoint site.

    I am totally stuck at this point - please help.....

    Thanx
    Monday, January 11, 2010 4:48 AM
  • If you store the js in document library, that means the anonymous users, who do not have any permission on the library, cannot get the js files.
    You need to place them in a physical location and perform the above steps. 

    Cogito, ergo sum.
    Monday, January 11, 2010 5:08 AM