Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The SetSecurityDescriptor method sets the security descriptor for the specified file, file share, or registry key.
HRESULT SetSecurityDescriptor(
[in] VARIANT varPath,
[in] long lPathFormat,
[in] VARIANT varData,
[in] long lDataFormat
);
[in] varPath
A VARIANT string that contains the path of the object to set the security descriptor for. Possible values are listed in the following list.
A valid file path syntax. For example: "c:\specs\public\adxml.doc" or "\adsi\public\dsclient.exe".
A valid file path syntax for a file share. For example: "\adsi\public".
A valid registry syntax. For example, "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs".
[in] lPathFormat
Contains one of the ADS_PATHTYPE_ENUM values which specifies the format of the varPath parameter.
[in] varData
A VARIANT that contains the new security descriptor. The format of the security descriptor is specified by the lDataFormat parameter.
[in] lDataFormat
Contains one of the ADS_SD_FORMAT_ENUM values which specifies the format of the security descriptor contained in the VarData parameter. The following list identifies the possible values for this parameter and the format of the VarData parameter.
Returns S_OK if successful or a COM or Win32 error code otherwise. Possible error codes are listed in the following list.
Access control entries must appear in the following order in a security descriptor's access control list:
The following code example shows how to set a security descriptor for a file.
Dim dacl as IADsAccessControlList
Dim sd as IADsSecurityDescriptor
Dim newAce as New AccessControlEntry
Dim sdUtil as New ADsSecurityUtility
Set sd = sdUtil.GetSecurityDescriptor("c:\specs\adsixml.doc", ADS_PATH_FILE, ADS_SD_FORMAT_IID )
Set dacl = sd.DiscretionaryAcl
' Add a new ACE for Jeff Smith.
newAce.Trustee = "Fabrikam\jeffsmith"
newAce.AccessMask = ADS_RIGHT_GENERIC_READ Or ADS_RIGHT_GENERIC_EXECUTE
newAce.AceType = ADS_ACETYPE_ACCESS_ALLOWED
dacl.AddAce newAce
sd.DiscretionaryAcl = dacl
sdUtil.SetSecurityDescriptor "c:\specs\adsixml.doc", ADS_PATH_FILE, sd, ADS_SD_FORMAT_IID
Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set dacl = Nothing
Set sd = Nothing
Set newAce = Nothing
Set sdUtil = Nothing
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | iads.h |
DLL | Activeds.dll |
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!