views:

96

answers:

0

I am using the following code to authenticate a user using Active Directory. But when I disable a user from AD, the change is not immediately reflected and the authentication still succeeds for some time after the disable. Can I force active directory updates through code? Thanks

DirectoryEntry entry = null;
try
{
    entry = new DirectoryEntry("LDAP://" + _domainName, pUserLogin, pPassword);
    entry.RefreshCache();
    object nativeObject = entry.NativeObject;
    return true;
}
catch (DirectoryServicesCOMException)
{
    return false;
}
finally
{
     if (entry != null)
     {
        entry.Close();
     }
}