INFO: UserDomain Method Does Not Work Under Win95 with WSH (188602)
The information in this article applies to:
- Microsoft Windows 95
- Microsoft Windows 98
This article was previously published under Q188602 SUMMARY
The Windows Script Host returns the Domain name that the client is
logging onto through the method UserDomain in the WScript.Network class.
Due to the differences between Windows NT and Windows 9x this method only
supports Windows NT clients. Instead of returning the domain name, when the
call to UserDomain is issued on the Windows 9x client the return value is a
blank string.
MORE INFORMATION
You might still need or want the domain name on Windows 9x clients. The
Windows 9x client's credentials will always send a value for the Domain
name.
To work around this problem you need to know where the Windows 9x client
gets its Domain name. If the Windows 9x client is not set to log on to a
Domain (through the "Log on to Windows NT domain" check box and text
entry), it will pass the Workgroup name of the client. Otherwise, it will
pass the value in the "Log on to Windows NT domain" text entry. NOTE: Even
if the check box is not selected and there is a name in the "Log on to
Windows NT domain" text entry, the Windows 9x client will still pass the
name as the Domain name.
IMPORTANT: This article contains information about editing the registry.
Before you edit the registry, make sure you understand how to restore it if
a problem occurs. For information about how to do this, view the "Restoring
the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key"
Help topic in Regedt32.exe.
The "Log on to Windows NT domain" entry is stored in the following registry
key:
HKey_Local_Machine\System\CurrentControlSet\Services\MSNP32\
NetworkProviderReg_SZ AuthenticatingAgent
NOTE: The above registry key is one path. It has been wrapped for
readability.
The "Log on to Windows NT domain" check box is stored in the following
registry key:
HKey_Local_Machine\Network\Logon Reg_DWORD LMLogon
(1=Checked 0=Unchecked)
The Workgroup name is stored in the following registry key:
HKey_Local_Machine\System\CurrentControlSet\Services\VxD\VNETSUP Reg_SZ
Workgroup
NOTE: The above registry key is one path. It has been wrapped for
readability.
The following is a Windows Script Host script written in VBScript that
demonstrates how to retrieve the domain name that would be sent in the
clients credentials on a Windows 9x client.
Sample Code
<Beginning of script>
Dim Domain
Dim WSHNetwork
Dim WSHShell
Dim WSHEnv
Const LogDomstr="HKLM\SYSTEM\CurrentControlSet\Services\MSNP32\
NetworkProvider\AuthenticatingAgent"
NOTE: The above string is one line. It has been wrapped for readability.
Const Workgroupstr = "HKLM\SYSTEM\CurrentControlSet\Services\VxD\
VNETSUP\Workgroup"
NOTE: The above string is one line. It has been wrapped for readability.
Set WSHNetwork = Wscript.CreateObject("Wscript.Network")
Set WSHShell = Wscript.CreateObject("Wscript.Shell")
Set WSHEnv = WSHShell.Environment
If (WSHEnv("OS") = "Windows_NT") Then
Domain = WSHNetwork.UserDomain
Else
Domain = WSHShell.RegRead(LogDomstr)
If (Domain = "") Then
Domain = WSHShell.RegRead(Workgroupstr)
End If
End If
MsgBox Domain
<End of script>
WARNING: Using Registry Editor incorrectly can cause serious problems that
may require you to reinstall your operating system. Microsoft cannot
guarantee that problems resulting from the incorrect use of Registry Editor
can be solved. Use Registry Editor at your own risk.
For information about how to edit the registry, view the "Changing Keys And
Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete
Information in the Registry" and "Edit Registry Data" Help topics in
Regedt32.exe. Note that you should back up the registry before you edit it.
If you are running Windows NT, you should also update your Emergency Repair
Disk (ERD).
Modification Type: | Minor | Last Reviewed: | 3/7/2005 |
---|
Keywords: | kbinfo KB188602 |
---|
|