Yinon Yamin | 1 Dec 2009 08:28
Favicon

Netapi for testjoin

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").

Thanks in advance, 

Yinon

Guenther Deschner | 1 Dec 2009 22:29
Picon
Favicon

Re: Netapi for testjoin

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
(Continue reading)

Yinon Yamin | 2 Dec 2009 10:05
Favicon

RE: Netapi for testjoin

Thanks for your quick answer.

I did try the NetGetJoinInformation() API and it didn't work for me.
I am using Samba 3.4.3 and the NetGetJoinInformation() always return as if I am connected to the domain.

-------------------
./bin/getjoininformation -S exanet-qa2 -U administrator%secret
Successfully queried join information:
c2-lnx2 is joined to domain EXANET-QA2

/usr/local/samba/bin/net ads leave -U administrator%secret
Deleted account for 'C2-LNX2' in realm 'EXANET-QA2.EXANET-IL.CO.IL'

./bin/getjoininformation -S exanet-qa2 -U administrator%secret
Successfully queried join information:
c2-lnx2 is joined to domain EXANET-QA2
-------------

I also tried to do the same with no_ads_support and I got the same results.

BTW: Why does the "net rpc" command don't support the 'leave' command ?

Yinon

-----Original Message-----
From: Guenther Deschner [mailto:gd <at> samba.org] 
Sent: Tuesday, December 01, 2009 23:30
To: Yinon Yamin
Cc: samba-technical <at> lists.samba.org
Subject: Re: Netapi for testjoin
(Continue reading)

Yinon Yamin | 2 Dec 2009 17:05
Favicon

RE: Netapi for testjoin

I looked again at the implementation of NetGetJoinInformation() and realized that it'd probably call 
the function "NetGetJoinInformation_l(struct libnetapi_ctx *ctx, struct NetGetJoinInformation *r)".

This function returns a static answer. It does not contact the AD to check my join status.

What do I miss?

Thanks

Yinon

-----Original Message-----
From: Guenther Deschner [mailto:gd <at> samba.org] 
Sent: Tuesday, December 01, 2009 23:30
To: Yinon Yamin
Cc: samba-technical <at> lists.samba.org
Subject: Re: Netapi for testjoin

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.
(Continue reading)


Gmane