On Wed, Nov 4, 2015 at 12:27 PM, Rowland Penny <rowlandpenny241155 at gmail.com> wrote:> On 04/11/15 17:11, pisymbol . wrote: >> >> On Wed, Nov 4, 2015 at 11:09 AM, mathias dufresne <infractory at gmail.com> >> wrote: >>> >>> Hi, >>> >>> Once you have installed Samba to be able to run it as Active Directory >>> you >>> would have samba-tool available. >>> >>> # which samba-tool >>> /usr/bin/samba-tool >>> # file /usr/bin/samba-tool >>> /usr/bin/samba-tool: Python script, ASCII text executable >>> # locate ldapcmp.py >>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.py >>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.pyc >>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.pyo >>> # file /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.py >>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.py: Python >>> script, >>> ASCII text executable >>> >>> I gave the commands because they help to find where are really these >>> files. >>> They could be in some other directory on your system. >>> There are a lot of other (python) files in there. >> >> >> Hmph. This command doesn't look like its shipped in the standard >> samba4 CentOS RPMS. Bummer. > > > This could be because it is part of a Samba4 AD DC setup and (all together > now) you cannot set up an AD DC with RHEL based distros yet with the distro > packages, use the Sernet packages instead.Rowland et al: It seems samba-tool, at least in itself, doesn't really have what I'm looking for (a 'net ads search' equivalent). However, I do see things in source4/scripting/bin like 'rpcclient' for instance (which doesn't really work for me due to either not being able to import some modules OR missing DEBUGLEVEL_CLASS if I muck with my PYTHONPATH). I see that samba-python includes SOs of various pertinent libraries (like srvsvc.so, winbind.so, netlogin.so, samr.so etc.). Is there any documentation at all on any of this stuff? Or are all of these APIs really for internal consumption only? -aps
Rowland Penny
2015-Nov-04 21:44 UTC
[Samba] Using samba-python to query AD? Status of API?
On 04/11/15 21:31, pisymbol . wrote:> On Wed, Nov 4, 2015 at 12:27 PM, Rowland Penny > <rowlandpenny241155 at gmail.com> wrote: >> On 04/11/15 17:11, pisymbol . wrote: >>> On Wed, Nov 4, 2015 at 11:09 AM, mathias dufresne <infractory at gmail.com> >>> wrote: >>>> Hi, >>>> >>>> Once you have installed Samba to be able to run it as Active Directory >>>> you >>>> would have samba-tool available. >>>> >>>> # which samba-tool >>>> /usr/bin/samba-tool >>>> # file /usr/bin/samba-tool >>>> /usr/bin/samba-tool: Python script, ASCII text executable >>>> # locate ldapcmp.py >>>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.py >>>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.pyc >>>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.pyo >>>> # file /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.py >>>> /usr/lib64/python2.7/site-packages/samba/netcmd/ldapcmp.py: Python >>>> script, >>>> ASCII text executable >>>> >>>> I gave the commands because they help to find where are really these >>>> files. >>>> They could be in some other directory on your system. >>>> There are a lot of other (python) files in there. >>> >>> Hmph. This command doesn't look like its shipped in the standard >>> samba4 CentOS RPMS. Bummer. >> >> This could be because it is part of a Samba4 AD DC setup and (all together >> now) you cannot set up an AD DC with RHEL based distros yet with the distro >> packages, use the Sernet packages instead. > Rowland et al: > > It seems samba-tool, at least in itself, doesn't really have what I'm > looking for (a 'net ads search' equivalent). However, I do see things > in source4/scripting/bin like 'rpcclient' for instance (which doesn't > really work for me due to either not being able to import some modules > OR missing DEBUGLEVEL_CLASS if I muck with my PYTHONPATH). > > I see that samba-python includes SOs of various pertinent libraries > (like srvsvc.so, winbind.so, netlogin.so, samr.so etc.). Is there any > documentation at all on any of this stuff? Or are all of these APIs > really for internal consumption only? > > -apsAh, you want to search AD with python, as in 'ldbsearch -H /usr/local/samba/private/sam.ldb' (this will dump the AD database) You will find lots of 'examples' in the python 'samba' directory that an install of a samba DC creates, these are used by samba-tool, well actually, they are samba-tool :-) Also have a look here: https://www.samba.org/~jelmer/samba4-python/moduleIndex.html Rowland
On Wed, Nov 4, 2015 at 4:44 PM, Rowland Penny <rowlandpenny241155 at gmail.com> wrote:> Ah, you want to search AD with python, as in 'ldbsearch -H > /usr/local/samba/private/sam.ldb' (this will dump the AD database) > You will find lots of 'examples' in the python 'samba' directory that an > install of a samba DC creates, these are used by samba-tool, well actually, > they are samba-tool :-)No, I don't want to dump the LDB, I want to query an actual Windows DC (same as 'net ads search' command).> Also have a look here: > https://www.samba.org/~jelmer/samba4-python/moduleIndex.htmlThat module listing is not very helpful in itself, but I'll take a look at the samba test examples to try to get a feel for it. -aps