Example #1
0
        internal override void Update(Principal p)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "SAMStoreCtx", "Update");

            Debug.Assert(p.fakePrincipal == false);
            Debug.Assert(p.unpersisted == false);
            Debug.Assert(p.UnderlyingObject != null);
            Debug.Assert(p.UnderlyingObject is DirectoryEntry);

            try
            {
                // Commit the properties
                SDSUtils.ApplyChangesToDirectory(
                    p,
                    this,
                    new SDSUtils.GroupMembershipUpdater(UpdateGroupMembership),
                    _credentials,
                    _authTypes
                    );

                // Reset the change tracking
                p.ResetAllChangeStatus();
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                throw ExceptionHelper.GetExceptionFromCOMException(e);
            }
        }
Example #2
0
        //
        // CRUD
        //

        // Used to perform the specified operation on the Principal.  They also make any needed security subsystem
        // calls to obtain digitial signatures.
        //
        // Insert() and Update() must check to make sure no properties not supported by this StoreCtx
        // have been set, prior to persisting the Principal.
        internal override void Insert(Principal p)
        {
            Debug.Assert(p.unpersisted == true);
            Debug.Assert(p.fakePrincipal == false);

            try
            {
                // Insert the principal into the store
                SDSUtils.InsertPrincipal(
                    p,
                    this,
                    new SDSUtils.GroupMembershipUpdater(UpdateGroupMembership),
                    _credentials,
                    _authTypes,
                    false               // handled in PushChangesToNative
                    );

                // Load in all the initial values from the store
                ((DirectoryEntry)p.UnderlyingObject).RefreshCache();

                // Load in the StoreKey
                Debug.Assert(p.Key == null);              // since it was previously unpersisted

                Debug.Assert(p.UnderlyingObject != null); // since we just persisted it
                Debug.Assert(p.UnderlyingObject is DirectoryEntry);
                DirectoryEntry de = (DirectoryEntry)p.UnderlyingObject;

                // We just created a principal, so it should have an objectSid
                Debug.Assert((de.Properties["objectSid"] != null) && (de.Properties["objectSid"].Count == 1));

                SAMStoreKey key = new SAMStoreKey(
                    this.MachineFlatName,
                    (byte[])de.Properties["objectSid"].Value
                    );
                p.Key = key;

                // Reset the change tracking
                p.ResetAllChangeStatus();

                GlobalDebug.WriteLineIf(GlobalDebug.Info, "SAMStoreCtx", "Insert: new SID is ", Utils.ByteArrayToString((byte[])de.Properties["objectSid"].Value));
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                throw ExceptionHelper.GetExceptionFromCOMException(e);
            }
        }