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

Vincent Le Toux vincent.letoux at gmail.com
Sat Oct 10 18:32:54 UTC 2020

> Hello,
> I'm trying to resolve SID from a linux using a program written in c#
> running under mono.
> I already know the Windows API LookupSID (
> https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-lookupaccountsida)
> and its underlying raw RPC call (
> https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lsat/eb7ac899-e697-4883-93de-1e60c7720c02
> ).
> I've also already implemented the raw RPC call on Windows in C# to be able
> to test null session
> (https://github.com/vletoux/pingcastle/blob/master/RPC/lsa.cs)
> So i understand what I'm doing.
> I want to port my c# program which is already running fine on Windows to
> Linux.
> I found some RPC call / API easily such as DsGetDcName (in libnetapi.so.0)
> I didn't find an easy export of LsarLookupSid because in general SID
> resolution is authenticated.
> I read (a lot) the samba source code and I found out many "kind" of lsa
> rpc implementation.
> The main one (and exported symbol on libsmbclient) is
> rpccli_lsa_lookup_sids. (I'm using nm -D)
> I also found dcerpc_lsa_lookup_sids in liblibcli-lsa.3
> The problem is by writting c# call, I've to write a lot of stuff and magic
> (called pinvoke) and I'm wasting a lot of time calling some functions,
> before finding out that there is no export is libsmbclient.
> I've tried indeed to port some code from rpcclient (the lsalookupsid
> function)
> My question is simple:
> can someone point me to the right flow of function calls so I can run this
> RPC call using the samba API with well known lib ?
> I think that
> rpccli_lsa_lookup_sids is the final call.
> Is this the case ?
> What the first call to do ?
> smbc_init ? (no return value to send to RPC in smbc_open ?)
> cli_full_connection ? (this export has no source code related ?)
> cli_full_connection_creds (no export  ?)
> Are there any things I missed ?
> Thanks in advance for your help
> best regards,
> Vincent LE TOUX

More information about the samba mailing list