ЖизниЛЕНТА

Copyright © 2007 Шапель Павел

Sharepoint Security and .NET Impersonation2

without comments

В продолжении поста Sharepoint Security and .NET Impersonation, WSA нашёл пример в MSDN по выполнению определённого кода под повышенными правами (под SHAREPOINT\System account identity)

SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate() {
  using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID)) {
    using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID)) {
      string SiteCollectionOwner = ElevatedsiteColl.Owner.Name;
      string Visits = ElevatedsiteColl.Usage.Visits.ToString();
      string RootAuditEntries =
          ElevatedSite.RootFolder.Audit.GetEntries().Count.ToString();
    }
  }
});

По-сути данный код делает тоже, что и наш самописный.

Written by Pash

Октябрь 30th, 2007 at 7:12 пп

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Reply