The invention provides a method and a device for controlling access security, wherein the method comprises the steps of establishing semantic web technology-based domain knowledge bases (including a domain ontology base, a domain example base and a domain rule base) and access control knowledge bases (including an access control ontology base, an access history ontology base and an access control policy rule base), when a user succeeds in accessing resources in the domain knowledge bases, recording the historical contents accessed by the user by an attribute example embodying method and generating an access control policy rule simultaneously, when the same user requests for accessing to the resources in the domain knowledge bases again, determining whether the access content of the user at the present time and the historical content accessed by the user previously break the made access policy rule, and if breaking the made access policy rule, rejecting the access request of the user at the present time, otherwise, allowing the access request of the user at the present time. The method and the device can be used for solving the security and privacy disclosure problems caused by context linkage between the contents accessed a plurality of times by the same user.