Пример #1
0
		public void CopyTo(AccessControlEntry[] array, int index) {
			if (array == null) 
				throw new ArgumentNullException();
			if (index < 0) 
				throw new ArgumentOutOfRangeException();
			throw new NotImplementedException();		
		}
Пример #2
0
		public int IndexOf(AccessControlEntry entry) {
			throw new NotImplementedException();
		}
Пример #3
0
		public bool Contains(AccessControlEntry entry) {
			throw new NotImplementedException();
		}
 public int IndexOf(AccessControlEntry entry)
 {
     return base.List.IndexOf(entry);
 }
Пример #5
0
 private static void AddACLEntry(AccessControlList acl, string aclEntry)
 {
     var ace = new AccessControlEntry();
     ace.Trustee = new Trustee(aclEntry);
     ace.EntryType = AccessControlEntryType.Set;
     ace.GenericAccessRights = GenericAccessRights.All;
     ace.StandardAccessRights = StandardAccessRights.All;
     acl.Add(ace);
 }
 public void Remove(AccessControlEntry entry)
 {
     base.List.Remove(entry);
 }
 public bool Contains(AccessControlEntry entry)
 {
     return base.List.Contains(entry);
 }
Пример #8
0
 /// <include file='doc\AccessControlList.uex' path='docs/doc[@for="AccessControlList.Contains"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public bool Contains(AccessControlEntry entry)
 {
     return(List.Contains(entry));
 }
Пример #9
0
 /// <include file='doc\AccessControlList.uex' path='docs/doc[@for="AccessControlList.Remove"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void Remove(AccessControlEntry entry)
 {
     List.Remove(entry);
 }
Пример #10
0
 public void Remove(AccessControlEntry entry)
 {
     throw new NotImplementedException();
 }
        internal IntPtr MakeAcl(IntPtr oldAcl)
        {
            IntPtr ptr;

            CheckEnvironment();
            int count = base.List.Count;

            System.Messaging.Interop.NativeMethods.ExplicitAccess[] accessArray = new System.Messaging.Interop.NativeMethods.ExplicitAccess[count];
            GCHandle handle = GCHandle.Alloc(accessArray, GCHandleType.Pinned);

            try
            {
                for (int i = 0; i < count; i++)
                {
                    int num4;
                    int sidSize              = 0;
                    int domainSize           = 0;
                    AccessControlEntry entry = (AccessControlEntry)base.List[i];
                    if (entry.Trustee == null)
                    {
                        throw new InvalidOperationException(Res.GetString("InvalidTrustee"));
                    }
                    string name = entry.Trustee.Name;
                    if (name == null)
                    {
                        throw new InvalidOperationException(Res.GetString("InvalidTrusteeName"));
                    }
                    if ((entry.Trustee.TrusteeType == TrusteeType.Computer) && !name.EndsWith("$"))
                    {
                        name = name + "$";
                    }
                    if (!System.Messaging.Interop.UnsafeNativeMethods.LookupAccountName(entry.Trustee.SystemName, name, IntPtr.Zero, ref sidSize, null, ref domainSize, out num4))
                    {
                        int num6 = Marshal.GetLastWin32Error();
                        if (num6 != 0x7a)
                        {
                            throw new InvalidOperationException(Res.GetString("CouldntResolve", new object[] { entry.Trustee.Name, num6 }));
                        }
                    }
                    accessArray[i].data = Marshal.AllocHGlobal(sidSize);
                    StringBuilder domainName = new StringBuilder(domainSize);
                    if (!System.Messaging.Interop.UnsafeNativeMethods.LookupAccountName(entry.Trustee.SystemName, name, accessArray[i].data, ref sidSize, domainName, ref domainSize, out num4))
                    {
                        throw new InvalidOperationException(Res.GetString("CouldntResolveName", new object[] { entry.Trustee.Name }));
                    }
                    accessArray[i].grfAccessPermissions     = entry.accessFlags;
                    accessArray[i].grfAccessMode            = (int)entry.EntryType;
                    accessArray[i].grfInheritance           = 0;
                    accessArray[i].pMultipleTrustees        = IntPtr.Zero;
                    accessArray[i].MultipleTrusteeOperation = 0;
                    accessArray[i].TrusteeForm = 0;
                    accessArray[i].TrusteeType = (int)entry.Trustee.TrusteeType;
                }
                int error = SafeNativeMethods.SetEntriesInAclW(count, handle.AddrOfPinnedObject(), oldAcl, out ptr);
                if (error != 0)
                {
                    throw new Win32Exception(error);
                }
            }
            finally
            {
                handle.Free();
                for (int j = 0; j < count; j++)
                {
                    if (accessArray[j].data != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(accessArray[j].data);
                    }
                }
            }
            return(ptr);
        }
Пример #12
0
 public void Insert(int index, AccessControlEntry entry)
 {
     throw new NotImplementedException();
 }
Пример #13
0
 public int IndexOf(AccessControlEntry entry)
 {
     throw new NotImplementedException();
 }
Пример #14
0
 public bool Contains(AccessControlEntry entry)
 {
     throw new NotImplementedException();
 }
Пример #15
0
		public void Insert(int index, AccessControlEntry entry) {
			throw new NotImplementedException();		
		}
Пример #16
0
        internal IntPtr MakeAcl(IntPtr oldAcl)
        {
            CheckEnvironment();

            int    ACECount = List.Count;
            IntPtr newAcl;

            NativeMethods.ExplicitAccess[] entries = new NativeMethods.ExplicitAccess[ACECount];

            GCHandle mem = GCHandle.Alloc(entries, GCHandleType.Pinned);

            try {
                for (int i = 0; i < ACECount; i++)
                {
                    int sidSize = 0;
                    int sidtype;
                    int domainSize = 0;

                    AccessControlEntry ace = (AccessControlEntry)List[i];

                    if (ace.Trustee == null)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.InvalidTrustee));
                    }

                    string name = ace.Trustee.Name;
                    if (name == null)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.InvalidTrusteeName));
                    }

                    if ((ace.Trustee.TrusteeType == TrusteeType.Computer) && !name.EndsWith("$"))
                    {
                        name += "$";
                    }

                    if (!UnsafeNativeMethods.LookupAccountName(ace.Trustee.SystemName, name, (IntPtr)0, ref sidSize, null, ref domainSize, out sidtype))
                    {
                        int errval = Marshal.GetLastWin32Error();
                        if (errval != 122)
                        {
                            throw new InvalidOperationException(Res.GetString(Res.CouldntResolve, ace.Trustee.Name, errval));
                        }
                    }

                    entries[i].data = (IntPtr)Marshal.AllocHGlobal(sidSize);

                    StringBuilder domainName = new StringBuilder(domainSize);
                    if (!UnsafeNativeMethods.LookupAccountName(ace.Trustee.SystemName, name, entries[i].data, ref sidSize, domainName, ref domainSize, out sidtype))
                    {
                        throw new InvalidOperationException(Res.GetString(Res.CouldntResolveName, ace.Trustee.Name));
                    }

                    entries[i].grfAccessPermissions     = ace.accessFlags;
                    entries[i].grfAccessMode            = (int)ace.EntryType;
                    entries[i].grfInheritance           = 0;
                    entries[i].pMultipleTrustees        = (IntPtr)0;
                    entries[i].MultipleTrusteeOperation = NativeMethods.NO_MULTIPLE_TRUSTEE;
                    entries[i].TrusteeForm = NativeMethods.TRUSTEE_IS_SID;
                    entries[i].TrusteeType = (int)ace.Trustee.TrusteeType;
                }

                int err = SafeNativeMethods.SetEntriesInAclW(ACECount, (IntPtr)mem.AddrOfPinnedObject(), oldAcl, out newAcl);

                if (err != NativeMethods.ERROR_SUCCESS)
                {
                    throw new Win32Exception(err);
                }
            }
            finally {
                mem.Free();

                for (int i = 0; i < ACECount; i++)
                {
                    if (entries[i].data != (IntPtr)0)
                    {
                        Marshal.FreeHGlobal(entries[i].data);
                    }
                }
            }


            return(newAcl);
        }
Пример #17
0
		public void Remove(AccessControlEntry entry) {
			throw new NotImplementedException();
		}
Пример #18
0
 /// <include file='doc\AccessControlList.uex' path='docs/doc[@for="AccessControlList.Add"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int Add(AccessControlEntry entry)
 {
     return(List.Add(entry));
 }
 public int Add(AccessControlEntry entry)
 {
     return base.List.Add(entry);
 }
Пример #20
0
 /// <include file='doc\AccessControlList.uex' path='docs/doc[@for="AccessControlList.Insert"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void Insert(int index, AccessControlEntry entry)
 {
     List.Insert(index, entry);
 }
 public void CopyTo(AccessControlEntry[] array, int index)
 {
     base.List.CopyTo(array, index);
 }
Пример #22
0
 /// <include file='doc\AccessControlList.uex' path='docs/doc[@for="AccessControlList.IndexOf"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public int IndexOf(AccessControlEntry entry)
 {
     return(List.IndexOf(entry));
 }
 public void Insert(int index, AccessControlEntry entry)
 {
     base.List.Insert(index, entry);
 }
Пример #24
0
        // 尝试初始化 MSMQ 环境
        public void InitialMsmq()
        {
            if (MsmqInitialized == true)
                return;

            if (string.IsNullOrEmpty(this.OutgoingQueue) == true)
            {
                // 清除 Hangup 状态
                if (this.ContainsHangup("MessageQueueCreateFail") == true)
                {
                    this.ClearHangup("MessageQueueCreateFail");
                    this.WriteErrorLog("*** 系统已解除 MessageQueueCreateFail 挂起状态");
                }
                return;
            }

            try
            {
#if NO
                            if (MessageQueue.Exists(this.OutgoingQueue))
                            {
                                MessageQueue.Delete(this.OutgoingQueue);
                            }
#endif

                if (!MessageQueue.Exists(this.OutgoingQueue))
                {
                    MessageQueue queue = MessageQueue.Create(this.OutgoingQueue);

#if NO
                                // Create an AccessControlList.
                                AccessControlList list = new AccessControlList();

                                // Create a new trustee to represent the "Everyone" user group.
                                Trustee tr = new Trustee("Everyone");

                                // Create an AccessControlEntry, granting the trustee read access to
                                // the queue.
                                AccessControlEntry entry = new AccessControlEntry(
                                    tr, GenericAccessRights.Read,
                         StandardAccessRights.Read,
                                    AccessControlEntryType.Allow);

                                // Add the AccessControlEntry to the AccessControlList.
                                list.Add(entry);


                                // Apply the AccessControlList to the queue.
                                queue.SetPermissions(list);
#endif

                    var wi = WindowsIdentity.GetCurrent();
                    if (wi.IsSystem == true)
                    {
                        // 当前用户已经是 LocalSystem 了,需要额外给 Everyone 添加权限,以便让 dp2Capo 的控制台方式运行能访问这个 Queue
                        queue.SetPermissions(@"Everyone",
    MessageQueueAccessRights.ReceiveMessage
    | MessageQueueAccessRights.DeleteMessage
    | MessageQueueAccessRights.PeekMessage
    | MessageQueueAccessRights.GenericRead);
                    }

                    // 如果当前是 Administrator,表示可能是 dp2libraryxe 启动的方式,那么需要专门给 LocalSystem 操作 Queue 的权限,以便 Windows Service 方式的 dp2Capo 能访问 Queue
                    var wp = new WindowsPrincipal(wi);
                    if (wp.IsInRole(WindowsBuiltInRole.Administrator))
                    {
                        queue.SetPermissions(@"NT AUTHORITY\System",
                            MessageQueueAccessRights.FullControl);
                    }

                    this.WriteErrorLog("首次创建 MSMQ 队列 '" + this.OutgoingQueue + "' 成功");
                }

                MsmqInitialized = true;
                // 清除 Hangup 状态
                if (this.ContainsHangup("MessageQueueCreateFail") == true)
                {
                    this.ClearHangup("MessageQueueCreateFail");
                    this.WriteErrorLog("*** 系统已解除 MessageQueueCreateFail 挂起状态");
                }
            }
            catch (Exception ex)
            {
                if (this.ContainsHangup("MessageQueueCreateFail") == true)
                {
                    this.WriteErrorLog("*** 重试探测和尝试创建 MSMQ 队列 '" + this.OutgoingQueue + "' 失败: " + ExceptionUtil.GetExceptionMessage(ex)
    + " 系统仍处于挂起状态。");
                }
                else
                {
                    this.AddHangup("MessageQueueCreateFail");
                    this.WriteErrorLog("*** 探测和尝试创建 MSMQ 队列 '" + this.OutgoingQueue + "' 时出现异常: " + ExceptionUtil.GetDebugText(ex)
                        + " 系统已被挂起。");
                }
            }
        }