Local outlier detection is able to capture local behavior to improve detection performance compared to traditional global outlier detection techniques. Most existing local outlier detection methods have the fundamental assumption that attributes and attribute values are independent and identically distributed (IID). However, in many situations, since the attributes usually have an inner structure, they should not be handled equally. To address the issue above, we propose a novel automatic context-based similarity metric for local outlier detection tasks. This paper mainly includes three aspects: (i) to propose a novel approach to automatically detect the contextual attributes by capturing the attribute intra-coupling and inter-coupling; (ii) to introduce a Non-IID similarity metric to derive the kNN set and reachability distance of an object based on the attribute structure and incorporate it into local outlier detection tasks; (iii) to build a data set called EG-Permission, which is a real-world data set from an E-Government Information System for context-based local outlier detection. Results obtained from 10 data sets show the proposed approach can identify the attribute structure effectively and improve the performance in local outlier detection tasks.