Code to return domain name?

uncle-lai

Registered User.
Local time
Today, 09:20
Joined
Aug 8, 2003
Messages
98
Hi,

Does anyone know how to return the network name with VB code? I wish I can restrict the use of my application in a special network. I think this is the only way to ensure that my mde file is not copied and used on other places than our company. I can't use user group control because I might not be able to manage that in the future.

Thanks for any suggestion or help.

Peter
 
Thanks Ghudson,

I am using Access 2000, the Environ() function does not work within access, it only works within VB Editor. And the string table does not include the Network Name.

What I want is to check the name of the Work Group that is listed under Microsoft Windows Network so that I can prevent the application from being run outside the company. In our company users do not have to log on to a server in order to enter the network, therefore the Logon Server Name is the same as the Computer Name. I understand that by checking the Network Name may not be very effective, just to reduce the possibilities. I believe the codes you posted in the thread from the first link can return the Network or Work Group Name, but I don't know how to modify them. I would appreciate very much if you could enlighten me further.
 
Last edited:
The environ function will work in any version of Access. It will work in a text box as simple as
=Environ("ComputerName")
You can call it within VBA anywhere you want.
Msgbox "Computer Name = " & Environ("ComputerName")
 
Thank you Ghudson. I will try again and do more detailed study.

Peter
 
These might interest you...

Code:
Msgbox "USER DNS DOMAIN = " & Environ("USERDNSDOMAIN")
Code:
Msgbox "USER DOMAIN = " & Environ("USERDOMAIN")
 
Hi Ghudson,

I still have no luck in solving my problem. I downloaded the Environment Variables mdb file. When I opened the form all the lines showed "#Name" in the text boxes. I was able to pull out all the viarables using a update query and put them into a table. However what I need was not there.

Actually the code "Environ("USERDOMAIN") should be the item I want if all users need to log on to a server, as normally practiced in most small businesses. Unfortunately in my case users only log on to their own computers, but share the storage on the server. I tried to find clues from the registry editor by searching the name of my work group. It was called "CSID" or "TSID" or "Last Domain". But I don't know how to retrieve it.

Or is there any way to prevent the program from being run out side the company other than verifying the work group name?

Peter
 
You are missing a reference if the Environ() does not work for you. Search around if you do not know how to verify/add/remove a reference.
 

Users who are viewing this thread

Back
Top Bottom