Results 1 to 9 of 9

Thread: setting file permission

  1. #1

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    setting file permission

    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

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Lookup the SetFileSecurity API function

  3. #3

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    thanks

    thanks for being so quick ... i will try it and get back to you

  4. #4

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    error

    VB Code:
    1. ' Attempt to get the ACL from the file's Security Descriptor.
    2.     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 ?

  5. #5

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    ??

    please reply ..... people

  6. #6
    Lively Member
    Join Date
    Jun 2002
    Posts
    111
    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?

  7. #7
    Junior Member
    Join Date
    Dec 2001
    Posts
    16

    Cool Try This :D

    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,
    Attached Files Attached Files

  8. #8
    Lively Member
    Join Date
    Jun 2002
    Posts
    111
    what I found as MSDN: msdn link

    [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
    edit - bad cuttin and pastin
    Last edited by Kantalope; Apr 24th, 2003 at 10:01 AM.

  9. #9

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    dumb

    that call was file system specific. it was meant for NTFS and i was trying it on FAT .

    good i figured out early

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width