My problem is the nearly the same of this thread :
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
I want add multiples users on a share by SID, I tried to follow this link :
The problem is the script looked if the user (or group) is in the domain before to get his SID but it's not my case.
I tried to add myself by SID, in my script.
NB: MyMap is a hashmap with key = group and value = SID
Someone can help me to fix my problem, I cannot create a share and add groups by SID, thanks.
!macro CreateNewShare NAME1 NAME2 NAME3 SHARENAME SHARE_TYPE SHARE_COMMENT SHARE_PERMISSIONS ACL_ACCESS MAX_USERS CURRENT_USES SHARE_PATH SHARE_PASS
${Map.Get} $SID MyMap ${NAME1}
System::Call 'ADVAPI32::ConvertStringSidToSid(ts,*p.r1)i.r5' "$SID"
${Map.Get} $SID MyMap ${NAME2}
System::Call 'ADVAPI32::ConvertStringSidToSid(ts,*p.r2)i.5' "$SID"
${If} ${NAME3} != ''
${Map.Get} $SID MyMap ${NAME3}
System::Call 'ADVAPI32::ConvertStringSidToSid(ts,*p.r3)i.r5' "$SID"
${Endif}
# Create an EXPLICIT_ACCESS structure that contains users and place it on $R6
System::Call /NOUNLOAD '*(i ${ACL_ACCESS},i ${SET_ACCESS},i ${NO_INHERITANCE},i 0,i ${NO_MULTIPLE_TRUSTEE},i ${TRUSTEE_IS_SID},i ${TRUSTEE_IS_GROUP},i $R9,i ${ACL_ACCESS},i ${SET_ACCESS},i ${NO_INHERITANCE},i 0,i ${NO_MULTIPLE_TRUSTEE},i ${TRUSTEE_IS_SID},i ${TRUSTEE_IS_GROUP},i $R7)i.R6'
System::Call /NOUNLOAD 'advapi32::SetEntriesInAclA(i $NBGROUP,i R6,,*i .R5)i.r1'
${If} $1 <> 0
System::Free $R6
Quit
${EndIf}
# Create an empty security descriptor and place it in R4.
System::Alloc ${NSIS_MAX_STRLEN}
Pop $R4
System::Call /NOUNLOAD 'advapi32::InitializeSecurityDescriptor(i R4,i ${SECURITY_DESCRIPTOR_REVISION})i.r1'
${If} $1 == 0
System::Free $R6
System::Call 'KERNEL32::LocalFree(pr1)'
System::Call 'KERNEL32::LocalFree(pr2)'
System::Call 'KERNEL32::LocalFree(pr3)'
System::Call 'kernel32::LocalFree(i R5)i.r0'
Quit
${EndIf}
# Add the ACL to the security descriptor
System::Call /NOUNLOAD 'advapi32::SetSecurityDescriptorDacl(i R4,i 1,i R5,i 0)i.r1'
${If} $1 == 0
System::Free $R6
System::Call 'KERNEL32::LocalFree(pr1)'
System::Call 'KERNEL32::LocalFree(pr2)'
System::Call 'KERNEL32::LocalFree(pr3)'
System::Call 'kernel32::LocalFree(i R5)i.r0'
Quit
${EndIf}
# Generate the structure that holds the share info and place it on $R0
System::Call /NOUNLOAD '*${strSHARE_INFO_502}("${SHARENAME}",${SHARE_TYPE},"${SHARE_COMMENT}",${SHARE_PERMISSIONS},${MAX_USERS},${CURRENT_USES},"${SHARE_PATH}","${SHARE_PASS}",0,R4).R0'
System::Call /NOUNLOAD 'netapi32::NetShareAdd(".", i 502, i R0, *i .R1) i .r1'
${If} $1 = 2118
${if} ${Silent}
!insertmacro SilentMode "Folder ${SHARE_PATH} has already been shared!"
Quit
${Else}
DetailPrint 'Folder "${SHARE_PATH}" has already been shared!'
FileWrite $LOG_FH 'Folder "${SHARE_PATH}" has already been shared!'
${EndIf}
${EndIf}
${If} $1 <> 0
${AndIf} $1 <> 2118
${if} ${Silent}
!insertmacro SilentMode "Error encountered while creating share ${SHARENAME} on ${SHARE_PATH}"
${Else}
DetailPrint 'Error encountered while creating share ${SHARENAME} on ${SHARE_PATH}'
FileWrite $LOG_FH 'Error encountered while creating share ${SHARENAME} on ${SHARE_PATH}$\r$\n'
${EndIf}
Abort
${Else}
DetailPrint "${SHARENAME} share added on ${SHARE_PATH}"
FileWrite $LOG_FH "${SHARENAME} share added on ${SHARE_PATH}$\r$\n"
${EndIf}
# Cleanup
System::Free $R6
System::Call 'KERNEL32::LocalFree(pr1)'
System::Call 'KERNEL32::LocalFree(pr2)'
System::Call 'KERNEL32::LocalFree(pr3)'
System::Call 'kernel32::LocalFree(i R5)i.r0'
System::Free $R0
!macroend