WMI security context

A

Angelo Campitelli

Hi,

I'm trying to run the following code on an account in a domain i.e
retrievesid "user","domainname".

The problem is im calling the code for a local administrators account which
has no priveleges in the domain. How do i query this using the security
context of a different user. I want to supply a username and password....

I read this in some WMi documentation.

If you must supply a username and password, you can't use the WMI moniker.
You must use the WMI Scripting Library's SWbemLocator object instead.

Any ideas ?

Function RetrieveSID (strUsername, strComputerordomainname)

Dim objWMIService
Dim objAccount

Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set objAccount = objWMIService.Get ("Win32_UserAccount.Name='" &
strUsername &"',Domain='" & strComputerordomainname & "'")

RetrieveSID = objAccount.SID

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top