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

wNT
plus

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

Determine if PC is Member of Domain


Question:

We currently have a very mixed environment of pc's. Of our W2K pc's some login to the domain, while some do not. I have an application that requires the pc to be in the domain before it can be installed. To properly define it I was mukking with the NetWork extender to verify that the domain admin group was part of the local administrator group. I am not able to do this very easily, and while beating my head against the wall figured *someone* must have done this before and done it well...as most of the folks here are MUCH better at WinBatch than myself...

So I guess the overall goal is...what is the simplest way to determine if a pc is in the domain or not.

Answer:

A quick search at groups.google.com came up with this:

http://groups.google.com/groups?q=Determine+PC+member+of+Domain&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=g%238UKan8CHA.1512%40cpmsftngxa08.phx.gbl&rnum=1

Apparently you can use the Win32 Network function wntLsaPolGet to retrieve domain information. Check the value of the security identifier (SID) field. If the value is NULL, the computer is either a stand-alone computer or part of a workgroup. If the Name field points to a string that matches the local workstation name, the computer is a stand-alone computer. Otherwise, the Name field points to the workgroup name.

If the SID pointer has a value, the computer is part of a domain. The domain name is stored in the Name field.

Try this code...

AddExtender("wwwnt34i.dll")
sid=wntLsaPolGet("","PrimaryDomain",2)
name=wntLsaPolGet("","PrimaryDomain",1)

If sid==""
  Message("Workgroup",name)
Else
  Message("Domain",StrCat(name,@CRLF,sid))
EndIf

Article ID:   W16042
File Created: 2004:03:30:15:42:28
Last Updated: 2004:03:30:15:42:28