private void SetObjectSecurityInCache()
 {
     if ((this.objectSecurity != null) && (this.objectSecurityModified || this.objectSecurity.IsModified()))
     {
         System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyValue value2 = (System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyValue) new System.DirectoryServices.Interop.UnsafeNativeMethods.PropertyValue();
         value2.ADsType     = 8;
         value2.OctetString = this.objectSecurity.GetSecurityDescriptorBinaryForm();
         System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyEntry varData = (System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyEntry) new System.DirectoryServices.Interop.UnsafeNativeMethods.PropertyEntry();
         varData.Name        = securityDescriptorProperty;
         varData.ADsType     = 8;
         varData.ControlCode = 2;
         varData.Values      = new object[] { value2 };
         ((System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyList) this.NativeObject).PutPropertyItem(varData);
     }
 }
 private ActiveDirectorySecurity GetObjectSecurityFromCache()
 {
     try
     {
         if (!this.JustCreated)
         {
             SecurityMasks securityMasks = this.Options.SecurityMasks;
             this.RefreshCache(new string[] { securityDescriptorProperty });
             if (!(this.NativeObject is System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyList))
             {
                 throw new NotSupportedException(Res.GetString("DSPropertyListUnsupported"));
             }
             System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyList  nativeObject = (System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyList) this.NativeObject;
             System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyEntry propertyItem = (System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyEntry)nativeObject.GetPropertyItem(securityDescriptorProperty, 8);
             GC.KeepAlive(this);
             object[] values = (object[])propertyItem.Values;
             if (values.Length < 1)
             {
                 throw new InvalidOperationException(Res.GetString("DSSDNoValues"));
             }
             if (values.Length > 1)
             {
                 throw new NotSupportedException(Res.GetString("DSMultipleSDNotSupported"));
             }
             System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyValue value2 = (System.DirectoryServices.Interop.UnsafeNativeMethods.IAdsPropertyValue)values[0];
             return(new ActiveDirectorySecurity((byte[])value2.OctetString, securityMasks));
         }
         return(null);
     }
     catch (COMException exception)
     {
         if (exception.ErrorCode != -2147463155)
         {
             throw;
         }
         return(null);
     }
 }