This paper addresses the access control issue for the comprehensive and distributed Internet of Things (IoT) environments. The typical eXtensible Access Control Markup Language (XACML) which implements the sophisticated access conditions in XML files, is widely used to guarantee access control decisions for the distributed IoT environments. To the best of our knowledge, the typical XACML-based access control schemes never consider the authentication run-time parameters. Moreover, the access control schemes that are mainly based on the typical XACML cannot secure themselves against some kinds of attacks, such as the Masquerade attack. Also, those schemes are not secure in opposition to Man-in-the-Middle (MITM) attack. Therefore, this paper proposes an adaptive XACML scheme that extends the typical XACML by integrating an access code generation and verification schemes for heterogeneous distributed IoT environments. Our adaptive XACML scheme considers some sensitive authentication run-time parameters before authorizing the user. Moreover, our scheme is proven secure against the Masquerade attack and MITM attack through hashing the generated access code using Message Digest Algorithm-5 (MD5) and Secure Hash Algorithm-1 (SHA-1) Checksum Utility. The experimental analysis of many different configurations supports the efficacy and efficiency of our adaptive XACML. It also shows exceptional compatibility and performance with different implementations. The processing time comparison between our adaptive XACML and Typical XACML, has shown that there is a low time overhead when using our adaptive XACML. This processing time overhead is nothing compared to the extra features that have been achieved in excess of the typical XACML and the security against Masquerade and MITM attacks. Therefore, our adaptive XACML scheme has the capability to be applied in various distinct distributed environments not only IoT.