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


  • 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


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

    string siteUrl = "";
    var secPwd = new SecureString();
    foreach (char c in "TenantAdminPwd".ToCharArray()) secPwd.AppendChar(c);

    var siteCtx = new ClientContext(siteUrl);
    siteCtx.Credentials = new SharePointOnlineCredentials("", secPwd);
    Site site = siteCtx.Site;


    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