0 out of 3 rated this helpful - Rate this topic

GetAccessMask method of the Win32_Share Class

Applies to: desktop apps only

The GetAccessMask method returns a uint32 bitmap with the access rights to the share held by the user or group on whose behalf the instance is returned.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax

uint32 GetAccessMask();

Parameters

This method has no parameters.

Return value

Value (const/dec/hex)Description
FILE_LIST_DIRECTORY
1 (0x1)

Grants the right to read data from the file. For a directory, this value grants the right to list the contents of the directory.

FILE_ADD_FILE
2 (0x2)

Grants the right to write data to the file. For a directory, this value grants the right to create a file in the directory.

FILE_ADD_SUBDIRECTORY
4 (0x4)

Grants the right to append data to the file. For a directory, this value grants the right to create a subdirectory.

FILE_READ_EA
8 (0x8)

Grants the right to read extended attributes.

FILE_WRITE_EA
16 (0x10)

Grants the right to write extended attributes.

FILE_TRAVERSE
32 (0x20)

Grants the right to execute a file. For a directory, the directory can be traversed.

FILE_DELETE_CHILD
64 (0x40)

Grants the right to delete a directory and all of the files it contains (its children), even if the files are read-only.

FILE_READ_ATTRIBUTES
128 (0x80)

Grants the right to read file attributes.

FILE_WRITE_ATTRIBUTES
256 (0x100)

Grants the right to change file attributes.

DELETE
65536 (0x10000)

Grants delete access.

READ_CONTROL
131072 (0x20000)

Grants read access to the security descriptor and owner.

WRITE_DAC
262144 (0x40000)

Grants write access to the discretionary access control list (DACL).

WRITE_OWNER
524288 (0x80000)

Assigns the write owner.

SYNCHRONIZE
1048576 (0x100000)

Synchronizes access and allows a process to wait for an object to enter the signaled state.

 

Examples

For more information and script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For more information and C++ code examples, see WMI C++ Application Examples.

The following VBScript code example creates a share folder and then gets the value of the access mask in the security descriptor that secures the share folder.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer _
    & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
Return = objNewShare.Create _
    ("C:\Temp", "TestShare", FILE_SHARE, _
        MAXIMUM_CONNECTIONS, "test share")

If Return <> 0 Then
          WScript.Echo Return
          WScript.Quit
End If

Set objShare = objWMIService.Get("Win32_Share.Name='TestShare'")
Return = objShare.GetAccessMask
WScript.Echo Return

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Namespace

\root\CIMV2

MOF

Cimwin32.mof

DLL

Cimwin32.dll

See also

Win32_Share

 

 

Send comments about this topic to Microsoft

Build date: 3/9/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
GetAccessMask method is dynamic

The documentation does not make it clear, but the GetAccessMask method is an object method and is used on an occurance of this class. You can see this with PowerShell as follows:

  PS c:\foo:\> Get-WMIOBjecct Win32_share | get-member  
    
  

TypeName: System.Management.ManagementObject#root\cimv2\Win32_Share

Name MemberType Definition
---- ---------- ----------
Delete Method System.Management.ManagementBaseObject Delete()
GetAccessMask Method
System.Management.ManagementBaseObject GetAccessMask()
SetShareInfo Method System.Management.ManagementBaseObject SetShareInfo(System.UInt32 MaximumAllowed, System.String Descr...
AccessMask Property System.UInt32 AccessMask {get;set;}
AllowMaximum Property System.Boolean AllowMaximum {get;set;}
Caption Property System.String Caption {get;set;}
Description Property System.String Description {get;set;}
InstallDate Property System.String InstallDate {get;set;}
MaximumAllowed Property System.UInt32 MaximumAllowed {get;set;}
Name Property System.String Name {get;set;}
Path Property System.String Path {get;set;}
Status Property System.String Status {get;set;}
Type Property System.UInt32 Type {get;set;}
__CLASS Property System.String __CLASS {get;set;}
__DERIVATION Property System.String[] __DERIVATION {get;set;}
__DYNASTY Property System.String __DYNASTY {get;set;}
__GENUS Property System.Int32 __GENUS {get;set;}
__NAMESPACE Property System.String __NAMESPACE {get;set;}
__PATH Property System.String __PATH {get;set;}
__PROPERTY_COUNT Property System.Int32 __PROPERTY_COUNT {get;set;}
__RELPATH Property System.String __RELPATH {get;set;}
__SERVER Property System.String __SERVER {get;set;}
__SUPERCLASS Property System.String __SUPERCLASS {get;set;}
PSStatus PropertySet PSStatus {Status, Type, Name}
ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime();
ConvertToDateTime ScriptMethod System.Object ConvertToDateTime();