IADsSecurityUtility::ConvertSecurityDescriptor method

The ConvertSecurityDescriptor method converts a security descriptor from one format to another.

Syntax


HRESULT ConvertSecurityDescriptor(
  [in]  VARIANT varSD,
  [in]  LONG    lDataFormat,
  [in]  LONG    lOutFormat,
  [out] VARIANT *pvResult
);

Parameters

varSD [in]

A VARIANT that contains the security descriptor to convert. The format of this VARIANT is defined by the lDataFormat parameter.

lDataFormat [in]

Contains one of the ADS_SD_FORMAT_ENUM values which specifies the format of the security descriptor in the varSD parameter. The following list identifies the possible values for this parameter and the format of the varSD parameter.

ADS_SD_FORMAT_IID

varSD contains a VT_DISPATCH that can be queried for the IADsSecurityDescriptor interface.

ADS_SD_FORMAT_RAW

varSD contains a VT_I1 | VT_ARRAY that contains the security descriptor in raw data format. This is in the format of a SECURITY_DESCRIPTOR structure.

ADS_SD_FORMAT_HEXSTRING

varSD contains a VT_BSTR that contains the raw security descriptor in hex encode string format.

lOutFormat [in]

Contains one of the ADS_SD_FORMAT_ENUM values which specifies the format that the security descriptor should be converted to. The following list identifies the possible values for this parameter and the format of the pvResult parameter.

ADS_SD_FORMAT_IID

pvResult receives a VT_DISPATCH that can be queried for the IADsSecurityDescriptor interface.

ADS_SD_FORMAT_RAW

pvResult receives a VT_I1 | VT_ARRAY that contains the security descriptor in raw data format. This is in the format of a SECURITY_DESCRIPTOR structure.

ADS_SD_FORMAT_HEXSTRING

pvResult receives a VT_BSTR that contains the raw security descriptor in hex encode string format.

pvResult [out]

Pointer to a VARIANT that receives the converted security descriptor. The format of the retrieved security descriptor is specified by the lOutFormat parameter.

Return value

Returns S_OK if successful or a COM or Win32 error code otherwise. Possible error codes include the following.

E_FAIL

An unspecified error occurred.

E_INVALIDARG

One or more parameters are invalid.

E_OUTOFMEMORY

A memory allocation failure occurred.

Examples

The following code example shows how to convert a security descriptor from IADsSecurityDescriptor interface format to hexadecimal string format.


Const ADS_SD_FORMAT_IID = 1
Const ADS_SD_FORMAT_HEXSTRING = 3

Dim sdUtil as New ADsSecurityUtility
Dim obj as IADs
Dim sd as IADsSecurityDescriptor
Dim sdInHex as VARIANT

Set obj = GetObject("LDAP://DC=MyDivision,DC=Fabrikam,DC=com")
Set sd = obj.Get("ntSecurityDescriptor")
sdInHex = sdUtil.ConvertSecurityDescriptor(sd, ADS_SD_FORMAT_IID, ADS_SD_FORMAT_HEXSTRING)

If (Err.Number<>0) Then
    MsgBox("An error has occurred. " & Err.Number)
End If
Set sdUtil = Nothing
Set obj = Nothing
Set sd = Nothing


Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Iads.h

DLL

Activeds.dll

IID

IID_IADsSecurityUtility is defined as A63251B2-5F21-474B-AB52-4A8EFAD10895

See also

ADS_PATHTYPE_ENUM
ADS_SD_FORMAT_ENUM
IADsSecurityDescriptor
IADsSecurityUtility

 

 

Show: