예제 #1
0
        private string GetStringValueHelper(LdapOption option, bool releasePtr)
        {
            if (_connection.disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            IntPtr outValue = new IntPtr(0);
            int    error    = Wldap32.ldap_get_option_ptr(_connection.ldapHandle, option, ref outValue);

            ErrorChecking.CheckAndSetLdapError(error);

            string s = null;

            if (outValue != (IntPtr)0)
            {
                s = Marshal.PtrToStringUni(outValue);
            }

            if (releasePtr)
            {
                Wldap32.ldap_memfree(outValue);
            }

            return(s);
        }
        private string GetStringValueHelper(LdapOption option, bool releasePtr)
        {
            if (this.connection.disposed)
            {
                throw new ObjectDisposedException(base.GetType().Name);
            }
            IntPtr outValue = new IntPtr(0);

            ErrorChecking.CheckAndSetLdapError(Wldap32.ldap_get_option_ptr(this.connection.ldapHandle, option, ref outValue));
            string str = null;

            if (outValue != IntPtr.Zero)
            {
                str = Marshal.PtrToStringUni(outValue);
            }
            if (releasePtr)
            {
                Wldap32.ldap_memfree(outValue);
            }
            return(str);
        }
예제 #3
0
 private string GetStringValueHelper(LdapOption option, bool releasePtr)
 {
     if (!this.connection.disposed)
     {
         IntPtr intPtr = new IntPtr(0);
         int    num    = Wldap32.ldap_get_option_ptr(this.connection.ldapHandle, option, ref intPtr);
         ErrorChecking.CheckAndSetLdapError(num);
         string stringUni = null;
         if (intPtr != (IntPtr)0)
         {
             stringUni = Marshal.PtrToStringUni(intPtr);
         }
         if (releasePtr)
         {
             Wldap32.ldap_memfree(intPtr);
         }
         return(stringUni);
     }
     else
     {
         throw new ObjectDisposedException(this.GetType().Name);
     }
 }