Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

GetObject causes "Unknown Exception"

  • Filter
  • Time
  • Show
Clear All
new posts

  • GetObject causes "Unknown Exception"

    I have a logon script which runs on all our XP machines with out a problem, however it is failing on our Win7 machines.

    When I run the script in my IDE, it fails at the GetObject line with error "Unknown Exception":

    Const cntYaLSVersion		= "0.1"
    numTimer			= Timer
    Set objWshNet 			= CreateObject("Wscript.Network")
    Set objRootDSE 			= GetObject("LDAP://RootDSE")
    strDomainDN			= objRootDSE.Get("defaultNamingContext")
    Set objRootDSE			= Nothing
    If I run the script from Windows Explorer, I get the error on the same line, but the error is:

    The specified domain either does not exist or could not be contacted. Error 8007054B

    I started a CMD as a Domain Admin and ran the script and it gets to line 687/8 and fails with another error, but I won't bring that one up here.

    Anyone know what the possible cause could be and how to fix it?
    +-- JDMils
    +-- Regional Systems Engineer, DotNet programmer & Jack of all trades

  • #2
    Re: GetObject causes "Unknown Exception"

    To get the Distinguished Name of the domain that the user authenticated to, try one of,

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    strNetBIOSDomain = WshNetwork.UserDomain
    With GetObject("LDAP://" & strNetBIOSDomain & "/RootDSE")
       strDomainDN = .Get("defaultNamingContext")
    End With
    wscript.echo strDomainDN
    OR Else

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    strNetBIOSDomain = WshNetwork.UserDomain
    Set oNT = CreateObject("NameTranslate") 
    oNT.Init 1, strNetBIOSDomain : oNT.Set 3, strNetBIOSDomain & "\"
    strDomainDN = oNT.Get(1)
    wscript.echo strDomainDN

    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts