i need to build an interface FROM WHERE i can set the permissions for a file.
i have managed to build a list of all users and groups in my net work but how can manage to give them rights for a perticular file in VB
any ideas would be appriciated
Printable View
i need to build an interface FROM WHERE i can set the permissions for a file.
i have managed to build a list of all users and groups in my net work but how can manage to give them rights for a perticular file in VB
any ideas would be appriciated
Lookup the SetFileSecurity API function
thanks for being so quick ... i will try it and get back to you
VB Code:
' Attempt to get the ACL from the file's Security Descriptor. lResult = GetAclInformation(pAcl, sACLInfo, Len(sACLInfo), 2&)
i am trying to set permission of a file but when vb reads this above line then vb .exe generates the error and whole vb shuts down.
to reduce mess i have mentioned the line which is giving me error to see the whole code you can go to this link
why this is happening .. any idea ?
please reply ..... people
I want to see the answer too...
Maybe if you posted more of the code, folks could help more.
The calls seem to be pretty OS specific (works for NT not Windows) could it be your Operating System?
This is working absolutly fine :)
Check the attached file, going home at 7:30 P.M. :(
Posting the answer so that if you got up at 3:00 A.M. you dont have to worry about anything and you can work on it ;)
Regards,
what I found as MSDN: msdn link
edit - bad cuttin and pastinQuote:
[Visual Basic]
The ChangeSecurityPermissions method changes the security permissions for the logical file specified in the object path. If the logical file is a directory, then this method will act recursively, changing the security permissions for all of the files and sub-directories that the directory contains. This method is inherited from CIM_LogicalFile.
For information about using this method with C/C++, see Calling a Method.
Function ChangeSecurityPermissions( _
ByVal SecurityDescriptor As Win32_SecurityDescriptor, _
ByVal Option As Integer _
) As Integer
Parameters
SecurityDescriptor
[in] Specifies the security information.
Note A NULL access control list (ACL) in the SECURITY_DESCRIPTOR structure grants unlimited access. For information about the implications of unlimited access, see Creating a Security Descriptor for a New Object.
Option
[in] Security privilege to modify. For example, to change the owner and DACL security, use:
Option = 1 + 4
or
Option = CHANGE_OWNER_SECURITY_INFORMATION | CHANGE_DACL_SECURITY_INFORMATIONValues to set the bit: Meaning
CHANGE_OWNER_SECURITY_INFORMATION
1 Change the owner of the logical file.
CHANGE_GROUP_SECURITY_INFORMATION
2 Change the group of the logical file.
CHANGE_DACL_SECURITY_INFORMATION
4 Change the ACL of the logical file.
CHANGE_SACL_SECURITY_INFORMATION
8 Change the system ACL of the logical file.
Return Values
Returns an integer value of 0 on success, and any other number to indicate an error.
Return Code Description
0 Success.
2 Access denied.
8 Unspecified failure.
9 Invalid object.
10 Object already exists.
11 File system not NTFS
12 Platform not Windows NT or Windows 2000.
13 Drive not the same.
14 Directory not empty.
15 Sharing violation.
16 Invalid start file.
17 Privilege not held.
21 Invalid parameter.
Remarks
The ChangeSecurityPermissions method in CIM_DataFile is implemented by WMI.
Requirements
Client: Included in Windows XP, Windows 2000 Professional, and Windows NT Workstation 4.0.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 4.0.
Header: Declared in Cimwin32.mof.
Namespace: Included in \root\cimv2.
See Also
CIM_DataFile
that call was file system specific. it was meant for NTFS and i was trying it on FAT .
good i figured out early :)