Partager via


SPChangeUser.IsSiteAdminChange - Propriété

Indique si la modification ajoute ou supprime les privilèges d'administrateur de site.

Espace de noms :  Microsoft.SharePoint
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
Public ReadOnly Property IsSiteAdminChange As Boolean
    Get
'Utilisation
Dim instance As SPChangeUser
Dim value As Boolean

value = instance.IsSiteAdminChange
public bool IsSiteAdminChange { get; }

Valeur de propriété

Type : System.Boolean
true si la modification ajoute ou supprime les privilèges d'administrateur de site ; dans le cas contraire, false.

Exemples

L'exemple suivant montre une application de console qui interroge le journal modification pour les modifications apportées aux utilisateurs de collection de sites. Il énumère les modifications (le cas échéant), puis imprime le nom de l'utilisateur, la date et le type de chaque modification apportée à la console. Si la modification de la collection de sites ajoute ou supprime les privilèges d'administrateur de site, l'application imprime ces informations à la console.

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using siteCollection As SPSite = New SPSite("https://localhost")
         Using webSite As SPWeb = siteCollection.RootWeb

            ' Construct a query.
            Dim query As New SPChangeQuery(False, False)

            ' Object type.
            query.User = True

            ' Change types. 
            query.Add = True
            query.Delete = True
            query.Update = True

            ' Get the user collection.
            Dim users As SPUserCollection = webSite.AllUsers

            While True
               Dim changes As SPChangeCollection = siteCollection.ContentDatabase.GetChanges(query)

               For Each change As SPChange In changes
                  ' Process Change.
                  Dim userChange As SPChangeUser = CType(change, SPChangeUser)

                  Try
                     ' Throws an exception if not found.
                     Dim user As SPUser = users.GetByID(userChange.Id) 
                     Console.WriteLine(ControlChars.Lf + "User {0} was changed.", user.LoginName)

                     If user.IsSiteAdmin Then
                        Console.WriteLine("This user is a site admin.")
                     End If

                  Catch ex As SPException
                     Console.WriteLine(ControlChars.Lf + "User {0} cannot be found", userChange.Id)
                  End Try

                  Console.WriteLine("Type of change: {0}", userChange.ChangeType.ToString())

                  If userChange.IsSiteAdminChange Then
                     Console.WriteLine("This change added or removed site admin privileges.")
                  End If

                  Console.WriteLine("Date of change: {0}", userChange.Time.ToShortDateString())

               Next change

               ' Break out of the loop when we fetch the last batch of changes.
               If changes.Count < SPChangeCollection.CountLimit Then
                  Exit While
               End If

               ' Go get another batch of changes starting where we left off.
               query.ChangeTokenStart = changes((changes.Count - 1)).ChangeToken

            End While

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub
End Module
using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite siteCollection = new SPSite("https://localhost"))
         {
            using (SPWeb webSite = siteCollection.RootWeb)
            {
               // Construct a query.
               SPChangeQuery query = new SPChangeQuery(false, false); 

               // Object type.
               query.User = true;

               // Change types. 
               query.Add = true;
               query.Delete = true;
               query.Update = true;

               // Get the user collection.
               SPUserCollection users = webSite.AllUsers;

               while (true)
               {
                  SPChangeCollection changes = siteCollection.ContentDatabase.GetChanges(query);

                  foreach (SPChange change in changes)
                  {
                     // Process change.
                     SPChangeUser userChange = (SPChangeUser)change;

                     try
                     {
                        SPUser user = users.GetByID(userChange.Id); // Throws an exception if not found
                        Console.WriteLine("\nUser {0} was changed.", user.LoginName);
                        if (user.IsSiteAdmin)
                        {
                           Console.WriteLine("This user is a site admin.");
                        }
                     }
                     catch (SPException)
                     {
                        Console.WriteLine("\nUser {0} cannot be found", userChange.Id);
                     }
                     Console.WriteLine("Type of change: {0}", userChange.ChangeType.ToString());
                     if (userChange.IsSiteAdminChange)
                        Console.WriteLine("This change added or removed site admin privileges.");
                     Console.WriteLine("Date of change: {0}", userChange.Time.ToShortDateString());
                  }

                  // Break out of the loop when we fetch the last batch of changes.
                  if (changes.Count < SPChangeCollection.CountLimit)
                     break;
                  // Go get another batch of changes starting where we left off.
                  query.ChangeTokenStart = changes[changes.Count - 1].ChangeToken;
               }
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}

Voir aussi

Référence

SPChangeUser classe

SPChangeUser - Membres

Microsoft.SharePoint - Espace de noms

IsSiteAdmin