1. A method for applying a security policy to an application session, comprising: recognizing the application session between a network and an application via a security gateway; retrieving by the security gateway an application session record for the application session, the application session record comprising a first user identity used for accessing the application through a first host, a first host identity for the first host, and an application session time; recognizing by the security gateway an access session between a second host and the network; retrieving by the security gateway an access session record for the access session, the access session record comprising a second user identity used for accessing the network through the second host, a second host identity for the second host, and an access session time; querying, by the security gateway, an identity server by sending the first host identity and the application session time in the application session record, the identity server comprising the access session record for the access session between the second host and the network; comparing, by the identity server, the first host identity in the application session record with the second host identity in the access session record, and comparing the access session time with the application session time; returning, by the identity server, the second user identity in the access session record if the first host identity in the application session record matches the second host identity in the access session record, and if the access session time matches the application session time; storing, at the identity server, the second user identity as a network user identity used for accessing the network in the application session record; determining by the security gateway at least one security policy applicable to the application session based on a group identity; and applying the at least one security policy to the application session by the security gateway if the network user identity is a member of the group identity.