static void ValidatePasTime() { string srvCertCN = "wcfservice"; NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; X509Certificate2 srvCert = CertManager.GetCertificateFromStorage(StoreName.TrustedPeople, StoreLocation.LocalMachine, srvCertCN); EndpointAddress address = new EndpointAddress(new Uri("net.tcp://localhost:9000/AuthenticationService"), new X509CertificateEndpointIdentity(srvCert)); using (AuthenticationServiceAuditProxy proxy = new AuthenticationServiceAuditProxy(binding, address)) { while (true) { try { List <string> loggedUsers = proxy.GetAllLoggedUsers(); Console.WriteLine($"Ima ih {loggedUsers.Count}"); foreach (string user in loggedUsers) { if (PasswordPolicy.ValidatePasswordTime(UserService.Instance.GetUser(user))) { proxy.LogOutClient(user, "Your password has been expired.Please conntact admin.You will be logged out..."); } } } catch (Exception e) { MyException ex = new MyException(); ex.Message = e.Message; throw new FaultException <MyException>(ex, new FaultReason(ex.Message)); } Thread.Sleep(PasswordPolicy.CheckPassword()); } } }