[Samba] Lookup sid with libsmbclient (invoked from c# on mono)

Vincent Le Toux vincent.letoux at gmail.com
Mon Oct 12 16:36:59 UTC 2020


This wrapper, I know how to make it in c#
(Rewriting stdin and stdout is not possible because I’m discovering one sid
after having examined another one)

What I’m missing is the api calls (in order) that I need to do to create
this connection.
Many exports that rpcclient is using are not included in libsmbdlient.
I can find the final rpc function, but not the functions to establish the
right context.
Rpcclient is using cli_ functions that are not found in other examples.

I need to know which c api to call in order to build the binding that the c
function you quote needs (the first input arg)

Br
Vincent

Le lun. 12 oct. 2020 à 18:23, Aurélien Aptel <aaptel at suse.com> a écrit :

> Vincent Le Toux via samba <samba at lists.samba.org> writes:
>
> > Indeed, rpcclient is the program I looked for the first time.
>
> >
>
> > I cannot invoke it in a command line because I have at least 1000 SID to
>
> > resolve
>
> > (I discover them one by one so I'll have to run rpcclient at least 1000
>
> > times)
>
>
>
> You can pass multiples SID at a time to these commands. But you would
>
> have to batch the resolving in your app.
>
>
>
> >
>
> > I looked at rpcclient source code, but there is no easy function such as
>
> > "connect" that can be used easily from libsmbclient
>
> >
>
> > Thinking about Smb_negox for example. I cannot just call
> structure->member
>
> > because I'll to translate all structure.
>
> > Working with pointer (IntPtr in c#) is much simpler.
>
>
>
> You can write a very simple C wrapper and call the wrapper from C#.
>
>
>
> So you would have:
>
>
>
> rpcwrapper.c:
>
>     void* init_connection(const char *user, const char *pw)
>
>     {
>
>         // establish connection and return handle
>
>     }
>
>
>
>     const char* name_to_sid(void *con, const char *name)
>
>     {
>
>         // use con to resolve and return sid
>
>     }
>
>
>
>     const char* sid_to_name(void *con, const char *sid)
>
>     {
>
>         // use con to resolve and return name
>
>     }
>
>
>
>     void free_connection(void *con)
>
>     {
>
>         // release con handle
>
>     }
>
>
>
> This wrapper would link against the same libs as rpcclient binary and
>
> would compile to librpcwrapper.so. From C you can #include all the
>
> struct definitions you need or copy them from the source code.
>
>
>
> Then from C# you just load librpcwrapper.so and call those simple
> functions.
>
>
>
> Cheers,
>
> --
>
> Aurélien Aptel / SUSE Labs Samba Team
>
> GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
>
> SUSE Software Solutions Germany GmbH, Maxfeldstr
> <https://www.google.com/maps/search/tions+Germany+GmbH,+Maxfeldstr?entry=gmail&source=g>.
> 5, 90409 Nürnberg, DE
>
> GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
>
> --
---
Vincent


More information about the samba mailing list