Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Lawrence Holcomb
RE: Global Account Problems [ reply ]  
2007-07-18 16:36
It's XP Pro Service Pack 2

Sys-admin is 1.4.2-win32

By: Lawrence Holcomb
RE: Global Account Problems [ reply ]  
2007-07-18 16:34
Sorry that was my bad too. I had tried that as it is properly documented but got the first error, then came back after doing something else and my mind was elsewhere.

I just added:

if user.respond_to?('localaccount') to the u.local = user.localaccount line and I'm getting a user object back now.

By: Daniel Berger
RE: Global Account Problems [ reply ]  
2007-07-18 16:30
That's odd. It shouldn't even be checking for localaccount if you've set the 3rd argument to false. I tried this here at work and it worked fine:

p Admin.get_user('djberge', nil, false)

What version of Windows, btw? And what version of sys-admin?

Regards,

Dan

By: Lawrence Holcomb
RE: Global Account Problems [ reply ]  
2007-07-18 16:23
That gives me WIN32OLERuntimeError: unknown property or method 'localaccount'

By: Daniel Berger
RE: Global Account Problems [ reply ]  
2007-07-18 16:21
Whoops, I meant, the default is true (local). To search for a global user, set the 3rd argument to false.

Sorry for the confusion.


By: Lawrence Holcomb
RE: Global Account Problems [ reply ]  
2007-07-18 16:21
Sorry forgot. Your snippet returns a Win32OLE object:

=> #<WIN32OLE:0x235e704>

By: Daniel Berger
RE: Global Account Problems [ reply ]  
2007-07-18 16:20
I see the problem. Try this:

Admin.get_user('glen', 'arachnia', false)

The 3rd argument is a boolean. The default is false (local).

I think I have that documented correctly, but I'll double check.

Regards,

Dan

By: Lawrence Holcomb
RE: Global Account Problems [ reply ]  
2007-07-18 16:15
I was just testing stuff in an irb session, here is a transcript:

require 'rubygems'
=> true
require 'sys/admin'
=> true
include Sys
=> Object
Admin.get_user('glen', 'arachnia', 'global')
=> nil
Admin.get_user('glen', 'global')
Sys::AdminError: #<Sys::AdminError:0x2b97ab0>

It would appear it is my fault for looking for a global account via the localhost. However I would expect the Admin.get_user('glen', 'arachnia', 'global') to return a user object.

I had actually started playing around after looking at your code and trying little pieces in irb. When I insert arachnia in place of #{host} in the wmi string I can query just fine (this is using irb again of course).

I'm not sure why it's returning nil rather than the user object though. In my irb session I get a user object that I can get values from:

wmi.execquery("select * from win32_useraccount where name = 'glen'").each do |user|
puts user.domain
puts user.fullname
puts user.sid
puts user.name
end
gives me sane output.

By: Daniel Berger
RE: Global Account Problems [ reply ]  
2007-07-18 16:01
Can you show me the code you're using? Also, what happens when you run this code snippet?

require 'win32ole'

host = Socket.gethostname
cs = "winmgmts:{impersonationLevel=impersonate}!//#{host}/root/cimv2"

wmi = WIN32OLE.connect(cs)

By: Lawrence Holcomb
Global Account Problems [ reply ]  
2007-07-18 14:15
Whenever I try to retrieve a global account (I'm assuming global means domain) I get a Sys::AdminError:0x2d67d40

It is coming from the wmi = WIN32OLE.connect(cs) line.

I know the account exists on the domain, it is the one I'm logged in as.

Any ideas?