public bool ValidatePasswordEncryptedWithSalt(byte[] clearSalt, byte[] sessionKey, _SAMPR_ENCRYPTED_USER_PASSWORD_NEW target)
        {
            _SAMPR_ENCRYPTED_USER_PASSWORD_NEW expected = GetPasswordEncryptedWithSalt(clearSalt, sessionKey);
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        /// <summary>
        /// Get the sibling nodes of the given tree node.
        /// </summary>
        /// <param name="nodeGuid">Tree node guid.</param>
        /// <returns>
        /// Return the guid array of the sibling nodes.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Thrown when the given node doesn't exist.
        /// </exception>
        internal Guid[] GetSiblingNodes(Guid nodeGuid)
        {
            if (!dataMap.ContainsKey(nodeGuid))
            {
                throw new ArgumentException("The given node doesn't exist.", "nodeGuid");
            }

            if (!parentNodeMap.ContainsKey(nodeGuid))
            {
                return(new Guid[] { });
            }

            List <Guid> tmpList = new List <Guid>();
            Guid        parent  = parentNodeMap[nodeGuid];

            foreach (Guid currentNode in childNodeMap[parent])
            {
                if (ObjectUtility.DeepCompare(currentNode, nodeGuid))
                {
                    continue;
                }
                tmpList.Add(currentNode);
            }

            return(tmpList.ToArray());
        }
        /// <summary>
        /// Validate the NT hash of the new password (as presented by the client) encrypted according to the
        /// specification of ENCRYPTED_NT_OWF_PASSWORD where the key is the 16-byte SMB session key established by
        /// the underlying authentication protocol(either Kerberos or NTLM).
        /// </summary>
        /// <param name="sessionKey">The session key used for encryption.</param>
        /// <param name="target"> the target to be validate</param>
        /// <returns>validate result</returns>
        public bool ValidateNewNtOwfPasswordEncryptedWithSessionKey(byte[] sessionKey, _ENCRYPTED_LM_OWF_PASSWORD target)
        {
            _ENCRYPTED_LM_OWF_PASSWORD expected = GetNewNtOwfPasswordEncryptedWithSessionKey(sessionKey);
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        public bool ValidateNewPasswordEncryptedWithOldNt(_SAMPR_ENCRYPTED_USER_PASSWORD target)
        {
            _SAMPR_ENCRYPTED_USER_PASSWORD expected = GetNewPasswordEncryptedWithOldNt();
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        public bool ValidateEncryptedNtOwfPasswordWithUserId(uint userId, _ENCRYPTED_LM_OWF_PASSWORD target)
        {
            _ENCRYPTED_LM_OWF_PASSWORD expected = GetEncryptedNtOwfPasswordWithUserId(userId);
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        public bool ValidateOldLmOwfPasswordEncryptedWithNewNt(_ENCRYPTED_LM_OWF_PASSWORD target)
        {
            _ENCRYPTED_LM_OWF_PASSWORD expected = GetOldLmOwfPasswordEncryptedWithNewNt();
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        public bool ValidateNewNtEncryptedWithNewLm(_ENCRYPTED_LM_OWF_PASSWORD target)
        {
            _ENCRYPTED_LM_OWF_PASSWORD expected = GetNewNtEncryptedWithNewLm();
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        /// <summary>
        /// Validate the existing password encrypted with session key.
        /// </summary>
        /// <param name="sessionKey">The session key used for encryption.</param>
        /// <param name="target"> the target to be validate</param>
        /// <returns>validate result</returns>
        public bool ValidateOldPasswordEncryptedWithSessionKey(byte[] sessionKey, _SAMPR_ENCRYPTED_USER_PASSWORD target)
        {
            _SAMPR_ENCRYPTED_USER_PASSWORD expected = GetOldPasswordEncryptedWithSessionKey(sessionKey);
            bool isSame = ObjectUtility.DeepCompare(expected, target);

            return(isSame);
        }
        /// <summary>
        /// Get the ancestor nodes of the given tree node.
        /// </summary>
        /// <param name="nodeGuid">Tree node guid.</param>
        /// <returns>
        /// Return the guid array of the ancestor nodes, whose order is from the parent node to root node.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Thrown when the given node doesn't exist.
        /// </exception>
        internal Guid[] GetAncestorNodes(Guid nodeGuid)
        {
            if (!dataMap.ContainsKey(nodeGuid))
            {
                throw new ArgumentException("The given node doesn't exist.", "nodeGuid");
            }

            if (ObjectUtility.DeepCompare(root.Value, nodeGuid))
            {
                return(new Guid[] { });
            }

            List <Guid> tmpList = new List <Guid>();

            Guid currentNode = nodeGuid;

            while (parentNodeMap.ContainsKey(currentNode))
            {
                currentNode = parentNodeMap[currentNode];
                tmpList.Add(currentNode);
            }

            return(tmpList.ToArray());
        }