Logon Server

  • Thread starter Thread starter Steve Lloyd
  • Start date Start date
S

Steve Lloyd

Hi,

I have created an application that works from scheduled tasks and uses the
System.Environment.GetEnvironmentVariable("LOGONSERVER") to identify which
server should be used form SMTP and Files, this works fine when a user is
logged in or the pc is logged in and locked.

However when the PC is not logged on the LOGONSERVER is a server on our
network but not the desired one. The schelduled task is set to "Run As" the
same user as above.

Can anyone shed any light on this or should i use something other than the
logonserver.

Thanks for any help

Steve Lloyd.
 
Steve,
If you are using Active Directory you can get the FQDN of the DC you are
connected to by using the following snippet. Make sure you reference
System.DirectoryServices and use an Imports System.DirectoryServices.

Dim Root As New DirectoryEntry("LDAP://RootDSE")
Dim LogonServer As String = Root.Properties("DNSHostName").Value
 
Back
Top