none
How to get site collection audit settings in SharePoint online using CSOM?

    Question

  • Hi, I want to read the available audit settings for all site collections in SharePoint Online using CSOM. In SharePoint On-Premise, we can easily get it through Get-SPSite from the property  $_.Audit.AuditFlags, but how can we read it in SPO using CSOM?
    • Edited by Morgan (MTS) Saturday, March 19, 2016 3:31 AM name change
    Friday, March 18, 2016 6:21 AM

Answers

  • I am just answering my own question. we can get it by using below csom C# code.

    string siteUrl = "https://MyTenant.sharepoint.com/sites/contoso/site1";
    var secPwd = new SecureString();
    foreach (char c in "TenantAdminPwd".ToCharArray()) secPwd.AppendChar(c);

    var siteCtx = new ClientContext(siteUrl);
    siteCtx.Credentials = new SharePointOnlineCredentials("admin@MyTenant.onmicrosoft.com", secPwd);
    Site site = siteCtx.Site;

    siteCtx.Load(site.Audit);
    siteCtx.ExecuteQuery();

    Console.WriteLine("AuditFlags: " + site.Audit.AuditFlags);

    • Marked as answer by Morgan (MTS) Saturday, March 19, 2016 3:52 AM
    Saturday, March 19, 2016 3:51 AM