Beispiel #1
0
        private static int BerScanfaString(BerSafeHandle berElement, char fmt, out object byteArray)
        {
            var result = IntPtr.Zero;

            byteArray = null;

            var rc = LdapNative.Instance.ber_scanf_ptr(berElement, new string(fmt, 1), ref result);

            try
            {
                if (rc != -1 && result != IntPtr.Zero)
                {
                    byteArray = MarshalUtils.GetBytes(result).ToArray();
                }
            }
            finally
            {
                if (result != IntPtr.Zero)
                {
                    LdapNative.Instance.ber_memfree(result);
                }
            }

            return(rc);
        }