WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Networks - Servers
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Sample Code Extracts Authenicating Server Name

Keywords:    netgetcon

Question:

I need to know which of our servers a user is logged onto as we have remote sites that need to handle the install locally.

Answer:

I have ran into alot of problems getting an NT login script to do both NT and 95.

If the server and the client are both nt4 sp3 then the DOS environment variable LOGONSERVER=\\servername. But you will have problems if you have a mixed environment (3.51 servers or non sp3 nt4).

One of the funky things I have found is that 95 maps drive Z: to the netlogon share of the DC that is authenticating you. Here is some code from my logon script to extract that information. Works quite well!

   AddExtender("www9534I.dll")
   AddExtender("wwnet34I.dll")

   username=w95UserInfo(0)
   NetLogonUNC=netGetCon("Z:")
   ServerString=(StrIndex(NetlogonUNC,"\",3,@fwdscan)-1)
   ServerUNC=StrSub(NetlogonUNC,1,ServerString)
   ServerName=StrSub(ServerUNC,3,(ServerString-2))
   logonserver="%ServerName%"

   Message(ProgVer,"username = %username%%LF%ServerString =%ServerString%%LF%ServerUNC = %ServerUNC%%LF%ServerName =%ServerName%%LF%logonserver = %logonserver%")

Question:

How can you determine the NT logon server used to validate a 95 client? There is no w9xUserInfo(3).

Answer:

During Windows 95 logon, the server that validates you will create a temporary connection to the netlogon share via the Z: drive. You can use the following to determine the validation server during login...
   netlogon=w95GetCon("Z:")
   logon_server=ItemExtract(3, netlogon, "\")
However, once login is complete, the drive mapping to the Z: drive is broken. The connection however will remain for a short time and can be determined by viewing all network resources...
   netlogon=w95Resources("DOMAIN", 1, 0, 0)
   For x=1 To ItemCount(netlogon, @Tab)
      logon=ItemExtract(x, netlogon, @Tab)
      If StrIndexNc(logon, "NETLOGON", 1, FWDSCAN) != 0 Then
         logon_server=ItemExtract(3, logon, "\")
         Break
      EndIf 
   Next x 

How to Map Drive to NetLogon Share to Get Around Z Drive Dropping the Connection Too Early

Here's some sample code from a user. It gets the current UNC for the Z: drive, and uses that in the NetAddDrive. This prevents the script from dropping the current connection by leaving the Z: drive mapped as is, and provides a clever way to load the WWW9534I.DLL from a mapped drive other than Z:.
   AddExtender("WWNET34I.DLL")


   w_directory = Environment("windir")
   file = "\\stealth\norton\updater.exe"
   drive = "U:"
   done = 0
   system = winmetrics(-4)
   nt_logon_ser = Environment("LOGONSERVER")
   nt_logon_ser = strcat(nt_logon_ser, "\netlogon")

   if system == 5
        log_ser = netGetCon("Z:")
        ErrorMode(@off) ; See warnings
        LastError()
        rslt0 = NetAddDrive(@DEFAULT,@DEFAULT,"%log_ser%", drive, @false)
        err=LastError()
        ErrorMode(@cancel)
        dirchange(drive)
        AddExtender("%drive%\WWW9534I.DLL")

   endif

Article ID:   W13495
Filename:   Sample Code Extracts Authenticating Server Name.txt
File Created: 2001:03:01:13:43:08
Last Updated: 2001:03:01:13:43:08