سؤال

I am trying to change a file's ownership through c++ in windows(windows 7 and up) to a specific user. I have read through this example but it does not seem to be of much help. I would like to be able to create a function like SetFileOwner(LPTSTR user, LPTSTR fileStr) that sets the owner of fileStr to be the specified user.

It seems that I need a SID to set the owner and then use SetNamedSecurityInfo. Is there another option that will allow me to set ownership by username? Is there a way to get SID from username(sorry if this question is stupid - I am not really into how windows rights and ownership work)?

هل كانت مفيدة؟

المحلول

To translate username to SID, use LookupAccountName.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top