0

Is is possible to check vpn connection or machine is connected to trusted network? My app need a connection to LDAP to get some data. this action is started when user login to machine and incase user working from outside of a trusted network (home network) and it causes problem when connecting to LDAP.

DirectoryEntry soRoot = new DirectoryEntry("LDAP://mydomain");
string ssDomainContext = soRoot.Properties["distinguishedName"].Value.ToString();

the block of code above will work correctly when machine is connected to VPN successful via Cisco Anyconnect or using office network (trusted network)

My concern is that whether we can detect the connection to VPN or LDAP right after the connection is established and then service will process for next step?

I am thinking about the way that connection will be checked in a loop of each time until the connection is finished but i think this is a wrong way

new user
  • 1
  • 1
  • The best way is to try LDAP and if you get an exception then try VPN. – jdweng Dec 21 '20 at 11:25
  • how many times that I should check ? I am just want to know right after the connection is established for processing next step... – new user Dec 21 '20 at 11:37
  • The connection will not be established if LDAP fails. So you try connection with LDAP and if it fails than try VPN. – jdweng Dec 21 '20 at 11:42
  • thanks for your reply, my concern is that how can we know right after LDAP is connected? for example: I write a function for checking LDAP connection in a loop of 5 minutes until LDAP is connected. Mean that if machine has a LDAP connection after 1 hour then we have 12 times of checking. Is it possible if we can check whenever a machine has a LDAP connection without in a loop time? – new user Dec 21 '20 at 12:28
  • Don't you have two conditions 1) Does connection complete (either LDAP or VPN) 2) Is connection still connected. – jdweng Dec 21 '20 at 12:42

0 Answers0