locked
Getting site collection admin in JavaScript RRS feed

  • Question

  • I want to get site collection admin for current site in JavaScript, I know how to do so in server side object model but still new to javascript ways.
    Friday, July 10, 2015 6:05 AM

Answers

  • I am afraid that there is no direct way to get all the Site collection administrator. You can easily check if the current logged in uses in Site Admin or not. You can check this link:

    http://sharepoint.stackexchange.com/questions/89604/check-an-admin-account-only-using-javascript

    Now for your requirement, you need all the site collection admins then 

    - you will need to get all the uses in the site collection and check who is site collection admin in JavaScript. here is 2 example on how to get all uses

    http://www.learningsharepoint.com/2011/10/15/retrieve-all-user-in-sharepoint-2010-site-using-javascript-client-object-model/

    https://msdn.microsoft.com/en-us/library/office/hh185012%28v=office.14%29.aspx?f=255&MSPPError=-2147217396

    check 'Retrieving All Users in All Groups of a Site Collection Using JavaScript' in above link.

    After getting all uses, you will need to check who has get_isSiteAdmin() property true to get the list of site collection admins.


    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

    Friday, July 10, 2015 7:02 AM
  • You can try it with REST:

    http://tenant/mywebsite/_api/site/owner

    Let me know if that helps you!


    Mohamed Derhalli

    SharePoint Consultant

    Blog: SharePoint Thoughts    Twitter:    LinkedIn:   

    • Marked as answer by Stefanie Liu Thursday, July 23, 2015 9:38 PM
    Friday, July 10, 2015 10:57 AM

All replies

  • I am afraid that there is no direct way to get all the Site collection administrator. You can easily check if the current logged in uses in Site Admin or not. You can check this link:

    http://sharepoint.stackexchange.com/questions/89604/check-an-admin-account-only-using-javascript

    Now for your requirement, you need all the site collection admins then 

    - you will need to get all the uses in the site collection and check who is site collection admin in JavaScript. here is 2 example on how to get all uses

    http://www.learningsharepoint.com/2011/10/15/retrieve-all-user-in-sharepoint-2010-site-using-javascript-client-object-model/

    https://msdn.microsoft.com/en-us/library/office/hh185012%28v=office.14%29.aspx?f=255&MSPPError=-2147217396

    check 'Retrieving All Users in All Groups of a Site Collection Using JavaScript' in above link.

    After getting all uses, you will need to check who has get_isSiteAdmin() property true to get the list of site collection admins.


    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

    Friday, July 10, 2015 7:02 AM
  • You can try it with REST:

    http://tenant/mywebsite/_api/site/owner

    Let me know if that helps you!


    Mohamed Derhalli

    SharePoint Consultant

    Blog: SharePoint Thoughts    Twitter:    LinkedIn:   

    • Marked as answer by Stefanie Liu Thursday, July 23, 2015 9:38 PM
    Friday, July 10, 2015 10:57 AM
  • Thanks Liu, This returns only one site collection admin user in spite of having 5 people in the Site collection Admin.  Do we have any way to retrieve the all the site collection admins ??

    Thanks & Regards,

    Siva


    • Edited by Cool Sivasankar Wednesday, November 18, 2015 10:45 PM additional info.
    Wednesday, November 18, 2015 10:44 PM