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

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


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)

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.

br
Vincent

Le lun. 12 oct. 2020 à 17:25, Aurélien Aptel via samba <
samba at lists.samba.org> a écrit :

> Rowland penny via samba <samba at lists.samba.org> writes:
> > I have no idea just what you are hoping to achieve, but it is seemingly
> > possible without authentication as 'wbinfo -n ACCOUNT_NAME' returns the
> > accounts SID. So try looking at the wbinfo code.
>
> wbinfo is talking to winbind which itself is talking to the AD. In this
> scenario the client previously joined (authenticated).
>
> What Vincent is after I think is a simple standalone way to query
> sid/names for his app to use that doesn't require seting up whole domain
> member. The rpcclient cli tool can do it.
>
> You can call the cli tool from your app (.110 is my AD ip, you can use
> hostnames too):
>
>     $ rpcclient -U administrator%mypassword -c 'lookupnames user1' //
> 192.168.2.110
>     user1 S-1-5-21-596735176-1287999152-3436313279-1104 (User: 1)
>     $ rpcclient -U administrator%mypassword -c 'lookupsids
> S-1-5-21-596735176-1287999152-3436313279-1104' //192.168.2.110
>     S-1-5-21-596735176-1287999152-3436313279-1104 NUC\user1 (1)
>
> ...Or copy the code (note that it is GPL though):
>
>
> https://gitlab.com/samba-team/devel/samba/-/blob/master/source3/rpcclient/cmd_lsarpc.c#L391
>
> 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. 5, 90409 Nürnberg, DE
> GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
>
> --
> To unsubscribe from this list go to the following URL and read the
> instructions:  https://lists.samba.org/mailman/options/samba
>


-- 
---
Vincent


More information about the samba mailing list