Bind to current computer object using VBScript

Bind to current computer object using VBScript

Post by <Ralph> » Thu, 07 Mar 2002 13:10:47



I want to be able to bind to the AD computer object for the computer I am
logged onto using VBScript in order to modify properties (I've dealt with
security permissions on those properties). I've been able to do this with an
ADO query to the GC with %computername% - is there an easier way?

Thanks!
Ralph

 
 
 

Bind to current computer object using VBScript

Post by Max L. Vaug » Fri, 08 Mar 2002 12:39:31


You have a couple of options.

Check out the ADsWinNTSystemInfo  and ADsDsSystemINfo objects.  They provide information about the current client.

Another method is to find the computer object in the AD, then bind to it using the LDAP provider.  If the machine is online, you can retrieve an Win32
_ComputerSystem object by calling the computer objects GetWMIObject method.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support

Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.

 
 
 

Bind to current computer object using VBScript

Post by Joe Richards [MVP » Sat, 09 Mar 2002 09:36:00


Maybe something like the following will work:

assuming nt4 style computer name in format of domain\hostname is in variable
computername

set o = createobject("NameTranslate")
o.init 3, ""
on error resume next
o.set 3, computername
dn=o.get(1)
on error goto 0

and then if it works you should have the dn to the computer and you should
be able bind to it.

--
Joe Richards
www.joeware.net
---


> I want to be able to bind to the AD computer object for the computer I am
> logged onto using VBScript in order to modify properties (I've dealt with
> security permissions on those properties). I've been able to do this with
an
> ADO query to the GC with %computername% - is there an easier way?

> Thanks!
> Ralph