If you have "add user script" Samba will calculate RID (the value after the last '-' in the SID) as: "(uid*2) + rid_offset". This rid_offset can be changed with "algorithmic rid base" smb.conf parameter but is usually left as 1000. The first part of the SID is the SID of your Domain.
