Netapi for testjoin

Guenther Deschner gd at samba.org
Tue Dec 1 14:29:51 MST 2009


Hi,

On Tue, Dec 01, 2009 at 09:28:14AM +0200, Yinon Yamin wrote:
> Hello everyone,
> 
>  
> 
> I am trying to write a small utility that can join, unjoin and testjoin
> to a DC.
> 
> For the join / unjoin I used the netapi  NetJoinDomain / NetunjoinDomain
> and it seems to work well.
> 
>  
> 
> The question is which API should I use in order to implement the
> testjoin predicate. 
> 
> The "testjoin " should return TRUE iff the host is already joined to the
> DC. (same functionality as the "net testjoin").

Hm, one thing you could do is to use the NetGetJoinInformation() API
(http://msdn.microsoft.com/en-us/library/aa370423%28VS.85%29.aspx)

-----8<------------------snip--------------8<--------------

see samba example code in:
lib/netapi/examples/join/getjoininformation.c

lib/netapi/examples/bin/getjoininformation -S xp -U administrator%secret
Successfully queried join information:
xp is joined to domain W2K3DOM

----->8------------------snap-------------->8--------------

that will work well against Windows.

alternatively you could use I_NetlogonControl{2} (only available in newer
libnetapi libs), with the NETLOGON_TC_VERIFY function_code:

-----8<------------------snip--------------8<--------------

see samba example code in:
lib/netapi/examples/netlogon/nltest.c

lib/netapi/examples/bin/nltest XP --sc_verify=W2K3DOM -U administrator%secret

----->8------------------snap-------------->8--------------

that also works well against Windows machines.

Unfortunately in w32 netapi there is no NetTestJoinDomain() call and thus
not in sambas libnetapi. That of course doesnt mean we could not just
invent such a call for Samba.

Guenther
-- 
Günther Deschner                    GPG-ID: 8EE11688
Red Hat                         gdeschner at redhat.com
Samba Team                              gd at samba.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20091201/c234b277/attachment.pgp>


More information about the samba-technical mailing list