Directory Services


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

HRESULT ConvertSecurityDescriptor( 
  LONG lDataFormat,
  LONG lOutFormat,
  VARIANT* pvResult


[in] A security descriptor source. A security descriptor used in the conversion of another security descriptor. After the call, the varSD will not change.
[in] Format of the security descriptor pointed to in varSD, as defined in ADS_SD_FORMAT_ENUM. The possible formats are IADsSecurityDescriptor interface, hexadecimal, or binary.
[in] Target format of the security descriptor. The possible conversion formats are defined in ADS_SD_FORMAT_ENUM.
[out] A security descriptor target. The result will be a security descriptor that has converted the content of varSD to the format described in lOutFormat.

Return Values

This method returns the standard return values, as well as the following.

For more information about other return values, see ADSI Error Codes.

Return Code Description
S_OK The conversion succeeded.

Example Code [Visual Basic]

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

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

On Error GoTo Cleanup

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


Client: Included in Windows XP.
Server: Included in Windows Server 2003.
Header: Declared in Iads.h.

See Also

ADS_PATHTYPE_ENUM, ADS_SD_FORMAT_ENUM, IADsSecurityDescriptor, IADsSecurityUtility, GetSecurityDescriptor, SetSecurityDescriptor