Calling winbind from C/C++

Mike Papper mike at digitalpipe.net
Wed Oct 17 13:42:02 GMT 2001


Heres what I include:

#include "includes.h"
#include "winbindd.h"

which is the same as "wbinfo.c"

using the following:
CPPFLAGS=-I/home/mike/work/samba/source 
-I/home/mike/work/samba/source/include -I/home/mike/work/samba/source/ubiqx 
-I/home/mike/work/samba/source/smbwrapper

I had to setup all those include dirs to get it to compile.
As C is cool, but when I compile as C++ I see the following:
--------------------------------------------------
g++  -I/home/mike/work/samba/source -I/home/mike/work/samba/source/include 
-I/home/mike/work/samba/source/ubiqx -I/home/mike/work/samba/source/smbwrapper
-I /home/mike/work/cda/comm -I/usr/local/pgsql/include  -I/usr/include/pgsql  
-c -o agent.o agent.cc
In file included from /home/mike/work/samba/source/include/smb.h:407,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from agent.cc:21:
/home/mike/work/samba/source/include/vfs.h:74: parse error before `new'
In file included from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from agent.cc:21:
/home/mike/work/samba/source/include/smb.h:662: parse error before `;'
In file included from /home/mike/work/samba/source/include/ntdomain.h:296,
                 from /home/mike/work/samba/source/include/rpc_misc.h:24,
                 from /home/mike/work/samba/source/include/smb.h:1521,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from agent.cc:21:
/home/mike/work/samba/source/include/rpc_spoolss.h:427: parse error before 
`private'
In file included from /home/mike/work/samba/source/include/smb.h:1523,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from agent.cc:21:
/home/mike/work/samba/source/include/nt_printing.h:224: parse error before 
`private'
In file included from /home/mike/work/samba/source/include/smb.h:1584,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from agent.cc:21:
/home/mike/work/samba/source/include/smb_acls.h:225: conflicting types for 
`typedef struct SMB_ACL_T
*SMB_ACL_T'
/home/mike/work/samba/source/include/smb_acls.h:223: previous declaration as 
`struct SMB_ACL_T'
/home/mike/work/samba/source/include/smb_acls.h:229: conflicting types for 
`typedef struct
SMB_ACL_ENTRY_T *SMB_ACL_ENTRY_T'
/home/mike/work/samba/source/include/smb_acls.h:227: previous declaration as 
`struct SMB_ACL_ENTRY_T'
In file included from /home/mike/work/samba/source/include/includes.h:707,
                 from agent.cc:21:
/home/mike/work/samba/source/include/proto.h:478: parse error before 
`template'
/home/mike/work/samba/source/include/proto.h:2734: parse error before 
`SEC_ACCESS'
/home/mike/work/samba/source/include/proto.h:4625: parse error before `new'
In file included from /home/mike/work/samba/source/include/rpc_client.h:25,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:116,
                 from agent.cc:22:
/home/mike/work/samba/source/include/rpc_client_proto.h:96: parse error 
before `unsigned'
agent.cc: In function `int print_domain_users ()':
agent.cc:74: no matching function for call to
`winbindd_request::winbindd_request (winbindd_cmd, NULL,
winbindd_response *)'
/home/mike/work/samba/source/nsswitch/winbindd_nss.h:121: candidates are:
winbindd_request::winbindd_request (const winbindd_request &)
/home/mike/work/samba/source/nsswitch/winbindd_nss.h:121:
winbindd_request::winbindd_request ()
make: *** [agent.o] Error 1
------------------------------------------------

If I omit the #include of the includes.h file, i get:

g++  -I/home/mike/work/samba/source -I/home/mike/work/samba/source/include 
-I/home/mike/work/samba/source/ubiqx 
-I/home/mike/work/samba/source/smbwrapper -I /home/mike/work/cda/comm 
-I/usr/local/pgsql/include  -I/usr/include/pgsql  -c -o agent.o agent.cc
In file included from /home/mike/work/samba/source/include/smb.h:407,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:28,
                 from agent.cc:22:
/home/mike/work/samba/source/include/vfs.h:74: parse error before `new'
In file included from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:28,
                 from agent.cc:22:
/home/mike/work/samba/source/include/smb.h:662: parse error before `;'
In file included from /home/mike/work/samba/source/include/ntdomain.h:296,
                 from /home/mike/work/samba/source/include/rpc_misc.h:24,
                 from /home/mike/work/samba/source/include/smb.h:1521,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:28,
                 from agent.cc:22:
/home/mike/work/samba/source/include/rpc_spoolss.h:427: parse error before 
`private'
In file included from /home/mike/work/samba/source/include/smb.h:1523,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:28,
                 from agent.cc:22:
/home/mike/work/samba/source/include/nt_printing.h:224: parse error before 
`private'
In file included from /home/mike/work/samba/source/include/smb.h:1584,
                 from /home/mike/work/samba/source/include/util_list.h:28,
                 from /home/mike/work/samba/source/include/includes.h:642,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:28,
                 from agent.cc:22:
/home/mike/work/samba/source/include/smb_acls.h:225: conflicting types for 
`typedef struct SMB_ACL_T
*SMB_ACL_T'
/home/mike/work/samba/source/include/smb_acls.h:223: previous declaration as 
`struct SMB_ACL_T'
/home/mike/work/samba/source/include/smb_acls.h:229: conflicting types for 
`typedef struct
SMB_ACL_ENTRY_T *SMB_ACL_ENTRY_T'
/home/mike/work/samba/source/include/smb_acls.h:227: previous declaration as 
`struct SMB_ACL_ENTRY_T'
In file included from /home/mike/work/samba/source/include/includes.h:707,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:28,
                 from agent.cc:22:
/home/mike/work/samba/source/include/proto.h:478: parse error before 
`template'
/home/mike/work/samba/source/include/proto.h:2734: parse error before 
`SEC_ACCESS'
/home/mike/work/samba/source/include/proto.h:4625: parse error before `new'
In file included from /home/mike/work/samba/source/include/rpc_client.h:25,
                 from /home/mike/work/samba/source/nsswitch/winbindd.h:116,
                 from agent.cc:22:
/home/mike/work/samba/source/include/rpc_client_proto.h:96: parse error 
before `unsigned'
agent.cc: In function `int print_domain_users ()':
agent.cc:74: no matching function for call to
`winbindd_request::winbindd_request (winbindd_cmd, NULL,
winbindd_response *)'
/home/mike/work/samba/source/nsswitch/winbindd_nss.h:121: candidates are:
winbindd_request::winbindd_request (const winbindd_request &)
/home/mike/work/samba/source/nsswitch/winbindd_nss.h:121:
winbindd_request::winbindd_request ()
make: *** [agent.o] Error 1
-----------------------------------------------------
Perhaps some doco on what are the right set of header files needed and what 
other libs are needed would be useful.

Mike Papper
-----------------------------------------------
On Wednesday 17 October 2001 01:11 am, Tim Potter wrote:
> Mike Papper writes:
> > I have downloaded and compile and installed the samba 2.2.2
> > with winbind. I have created a C program that acts like (my
> > own) version of wbinfo - it calls
> >
> > winbindd_request(WINBINDD_LIST_USERS, NULL, &response)
> >
> > and links with libsmbclient and libnss_winbind. This actually works, I am
> > able to talk to the winbind server to get a list of users on the
> > "system".
> >
> > However, this does not work when I try to use it in a C++
> > program. When I include nsswitch/winbindd.h
> > nsswitch/winbindd_nss.h etc. I get compile errors complaining
> > about uses of "new" and "class" (which extern "C" doesnt deal
> > with).
>
> There are no occurences of "new" or "class" in any of the header
> files in nsswitch.  Can you be a bit more precise about the error
> you are getting here?
>
> I (or someone) really needs to write a much nicer client
> interface to winbind that you can link in to your funky programs
> without having to pull in too many header files and so on.  It's
> a bit ad-hoc at the moment.
>
> > The questions:
> > -should I be able to use winbind to talk to the windbind server? It
> > appears
>
> Yes.
>
> > that the functions in libsmbclient do not do what I want at all (they
> > open files and create dirs). I know I can call getpwent to get a list of
> > users -
>
> libsmbclient and winbind should be completely separate
> libraries.  I don't think the interact at all.
>
>
> Tim.

-- 
Mike Papper
Digital Pipe
mike at digitalpipe.net
650-627-5100 ext. 5211




More information about the samba-technical mailing list