Esempio n. 1
0
            /// <summary>Initializes a new <see cref="PSID"/> instance from a SID authority and subauthorities.</summary>
            /// <param name="sidAuthority">The SID authority.</param>
            /// <param name="subAuth0">The first subauthority.</param>
            /// <param name="subAuthorities1to7">Up to seven other subauthorities.</param>
            /// <returns>A new <see cref="PSID"/> instance.</returns>
            /// <exception cref="System.ArgumentOutOfRangeException">
            /// <paramref name="sidAuthority"/> is null or an invalid length or more than 8 total subauthorities were submitted.
            /// </exception>
            public static PSID Init(PSID_IDENTIFIER_AUTHORITY sidAuthority, int subAuth0, params int[] subAuthorities1to7)
            {
                if (sidAuthority == null)
                {
                    throw new ArgumentOutOfRangeException(nameof(sidAuthority));
                }
                if (subAuthorities1to7.Length > 7)
                {
                    throw new ArgumentOutOfRangeException(nameof(subAuthorities1to7));
                }
                var res = IntPtr.Zero;

                try
                {
                    AllocateAndInitializeSid(sidAuthority, (byte)(subAuthorities1to7.Length + 1),
                                             subAuth0,
                                             subAuthorities1to7.Length > 0 ? subAuthorities1to7[0] : 0,
                                             subAuthorities1to7.Length > 1 ? subAuthorities1to7[1] : 0,
                                             subAuthorities1to7.Length > 2 ? subAuthorities1to7[2] : 0,
                                             subAuthorities1to7.Length > 3 ? subAuthorities1to7[3] : 0,
                                             subAuthorities1to7.Length > 4 ? subAuthorities1to7[4] : 0,
                                             subAuthorities1to7.Length > 5 ? subAuthorities1to7[5] : 0,
                                             subAuthorities1to7.Length > 6 ? subAuthorities1to7[6] : 0,
                                             out res);
                    return(CreateFromPtr(res));
                }
                finally
                {
                    FreeSid(res);
                }
            }
Esempio n. 2
0
 /// <summary>Initializes a new <see cref="SafePSID"/> instance from a SID authority and subauthorities.</summary>
 /// <param name="sidAuthority">The SID authority.</param>
 /// <param name="subAuth0">The first subauthority.</param>
 /// <param name="subAuthorities1to7">Up to seven other subauthorities.</param>
 /// <returns>A new <see cref="SafePSID"/> instance.</returns>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// <paramref name="sidAuthority"/> is null or an invalid length or more than 8 total subauthorities were submitted.
 /// </exception>
 public static SafePSID Init(PSID_IDENTIFIER_AUTHORITY sidAuthority, int subAuth0, params int[] subAuthorities1to7)
 {
     if (sidAuthority == null)
     {
         throw new ArgumentOutOfRangeException(nameof(sidAuthority));
     }
     if (subAuthorities1to7.Length > 7)
     {
         throw new ArgumentOutOfRangeException(nameof(subAuthorities1to7));
     }
     AllocateAndInitializeSid(sidAuthority, (byte)(subAuthorities1to7.Length + 1),
                              subAuth0,
                              subAuthorities1to7.Length > 0 ? subAuthorities1to7[0] : 0,
                              subAuthorities1to7.Length > 1 ? subAuthorities1to7[1] : 0,
                              subAuthorities1to7.Length > 2 ? subAuthorities1to7[2] : 0,
                              subAuthorities1to7.Length > 3 ? subAuthorities1to7[3] : 0,
                              subAuthorities1to7.Length > 4 ? subAuthorities1to7[4] : 0,
                              subAuthorities1to7.Length > 5 ? subAuthorities1to7[5] : 0,
                              subAuthorities1to7.Length > 6 ? subAuthorities1to7[6] : 0,
                              out var res);
     return(new SafePSID(res));
 }
Esempio n. 3
0
 public static extern bool InitializeSid(PSID Sid, PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, byte nSubAuthorityCount);
Esempio n. 4
0
 public static extern bool AllocateAndInitializeSid([In] PSID_IDENTIFIER_AUTHORITY sia,
                                                    byte subAuthorityCount, int dwSubAuthority0, int dwSubAuthority1,
                                                    int dwSubAuthority2, int dwSubAuthority3, int dwSubAuthority4,
                                                    int dwSubAuthority5, int dwSubAuthority6, int dwSubAuthority7, out SafeAllocatedSID pSid);