Fix mode
Active Directory conditional from Per Olofsson (@MagerValp)