lookupaccountname and workgroups

L

lasso

hello,

i asked this question in win32.programming.networks but got the advice to
try here, so here we go...

my basic problem is, when im calling LookupAccountName on a process running
as localsystem when not member of a domain (i.e., the machine is in a
workgroup) it returns 1332: no mapping between account names and security ids
was done.

i have been experimenting a bit using a small program similar to this
pseudo-c++:

string username
GetUserNameEx (NameSamCompatible, username, username.length)
print (username)
string domainname
// the sid things here are out parameters not relevant for my example
if (LookupAccountName (NULL, username, sidbuf, sidbuf.length, domainname,
domainname.length, sidthing)) {
print (domainname)
} else {
print (geterror ())
}

when running as user on a machine on a domain i get:
username: mydomain\jdoe
domainname: mydomain
running as localsystem on a domain i get:
username: mydomain\mycomputer$
domain: mydomain
but, running as user on a machine in a workgroup i get:
username: mycomputer\jdoe
domain: mycomputer
and finally, running as localsystem when in a workgroup i get:
username: workgroup\mycomputer$
domainname fails with 1332 as noted above

an interesting side note is that the domain part of the username differs in
the last two examples...

after some trial and error i discovered that if i removed the domain part
and the trailing $ from the username the call to lookupaccountname succeeds,
but returns the same domainname as username (e.g., mycomputer in the example
above).

do i have to make a condition like if (in_workgroup && localsystem) { ... }
or have i got something else wrong here?

regards,

lars
 
A

Anteaus

Was looking into this a while back in connection with mylogon - and came to
the conclusion that there is no easy answer. For some strange reason the OS
will not tell you conclusively if the computer is a domain or workgroup
member.

Why? Not sure.

If anyone knows an aswer... here's someone else who would like to know!

"lasso" wrote:

> my basic problem is, when im calling LookupAccountName on a process running
> as localsystem when not member of a domain (i.e., the machine is in a
> workgroup) it returns 1332: no mapping between account names and security ids
> was done.
 
Back
Top Bottom