ohh, i see you are setting the variable $ADS_SID_WINNT_PATH... but you are creating it as a string.

Have you tried creating it as a numeric number?

$ADS_SID_WINNT_PATH = 5

Also... you do have the ADSSECURITY.DLL registered?