We help IT Professionals succeed at work.

WScript.Network problem when compiled

scotiaceilidh
on
I have a problem with my compiled code.  When the code is running under my environment and I can step through it, I have no worries, but once I compile the code into a DLL, the following function returns nothing instead of the User's Domain.  Here is the code, anyone with a clue?  

'Function that grabs the Domain the User's NT Login Account is on
Public Function Domain() As String
   Dim wshNet As Object
   Set wshNet = CreateObject("WScript.Network")
   On Error GoTo errBadNetwork
   Domain = wshNet.UserDomain
   Dim i As Long
   Set wshNet = Nothing
   Exit Function
errBadNetwork:
   Domain = "Unavailable"
End Function
Comment
Watch Question

IT Operations
CERTIFIED EXPERT
Commented:
You could use API instead of an object.
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As LongDeclare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

dim sbuffer as string * 255
dim ret as long
ret= getusername(sBuffer,255)
msgbox left$(sbuffer,ret)

Author

Commented:
Thanks Richie,
But this gives me the wrong info.  I am getting only the parent domain and not the specific domain i need.

Author

Commented:
I there an API call that would provide me with the specific Domain my computer is registered on with.  ( I am using Novell, and it's this Domain info that I login with that I need to be able to grab.)

Author

Commented:
ok,
So Microsoft Tech net says WScript.Network will work in an object.

http://support.microsoft.com/support/kb/articles/Q279/1/64.ASP

And gives this example;

<%
dim objWSH
Set objWSH = Server.CreateObject("WScript.Network")
Response.Write (objWSH.UserDomain)
Response.Write objWSH.Username
%>

The Username work, but the UserDomain does not.  The code IS WORKING with my project running, but not when it's compliled.  Any Ideas??
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
By compiled, you mean in developer Pc on another one?
If is another one, maybe dll is missing or something.
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
I have compiled an active x dll with your code and it works!

Author

Commented:
OK, Thanks for sticking in there Richie, just to let you know I will be asking a related question soon.
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
Good!
How it happens?
I didn't add nothing more to code!
Which code did you use?
Cheers