Example #1
0
        private void SetStringValueHelper(LdapOption option, string value)
        {
            if (_connection.disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            IntPtr inValue = new IntPtr(0);

            if (value != null)
            {
                inValue = Marshal.StringToHGlobalUni(value);
            }

            try
            {
                int error = Wldap32.ldap_set_option_ptr(_connection.ldapHandle, option, ref inValue);
                ErrorChecking.CheckAndSetLdapError(error);
            }
            finally
            {
                if (inValue != (IntPtr)0)
                {
                    Marshal.FreeHGlobal(inValue);
                }
            }
        }
Example #2
0
 private void SetStringValueHelper(LdapOption option, string value)
 {
     if (!this.connection.disposed)
     {
         IntPtr intPtr = new IntPtr(0);
         if (value != null)
         {
             intPtr = Marshal.StringToHGlobalUni(value);
         }
         try
         {
             int num = Wldap32.ldap_set_option_ptr(this.connection.ldapHandle, option, ref intPtr);
             ErrorChecking.CheckAndSetLdapError(num);
         }
         finally
         {
             if (intPtr != (IntPtr)0)
             {
                 Marshal.FreeHGlobal(intPtr);
             }
         }
         return;
     }
     else
     {
         throw new ObjectDisposedException(this.GetType().Name);
     }
 }
Example #3
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 void SetIntValueHelper(LdapOption option, int value)
        {
            if (this.connection.disposed)
            {
                throw new ObjectDisposedException(base.GetType().Name);
            }
            int inValue = value;

            ErrorChecking.CheckAndSetLdapError(Wldap32.ldap_set_option_int(this.connection.ldapHandle, option, ref inValue));
        }
        private void ProcessCallBackRoutine(System.DirectoryServices.Protocols.ReferralCallback tempCallback)
        {
            LdapReferralCallback outValue = new LdapReferralCallback {
                sizeofcallback = Marshal.SizeOf(typeof(LdapReferralCallback)),
                query          = (tempCallback.QueryForConnection == null) ? null : this.queryDelegate,
                notify         = (tempCallback.NotifyNewConnection == null) ? null : this.notifiyDelegate,
                dereference    = (tempCallback.DereferenceConnection == null) ? null : this.dereferenceDelegate
            };

            ErrorChecking.CheckAndSetLdapError(Wldap32.ldap_set_option_referral(this.connection.ldapHandle, LdapOption.LDAP_OPT_REFERRAL_CALLBACK, ref outValue));
        }
        private int GetIntValueHelper(LdapOption option)
        {
            if (this.connection.disposed)
            {
                throw new ObjectDisposedException(base.GetType().Name);
            }
            int outValue = 0;

            ErrorChecking.CheckAndSetLdapError(Wldap32.ldap_get_option_int(this.connection.ldapHandle, option, ref outValue));
            return(outValue);
        }
Example #7
0
        private void SetIntValueHelper(LdapOption option, int value)
        {
            if (_connection.disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            int temp  = value;
            int error = Wldap32.ldap_set_option_int(_connection.ldapHandle, option, ref temp);

            ErrorChecking.CheckAndSetLdapError(error);
        }
Example #8
0
        private void ProcessCallBackRoutine(ReferralCallback tempCallback)
        {
            LdapReferralCallback value = new LdapReferralCallback();

            value.sizeofcallback = Marshal.SizeOf(typeof(LdapReferralCallback));
            value.query          = tempCallback.QueryForConnection == null ? null : _queryDelegate;
            value.notify         = tempCallback.NotifyNewConnection == null ? null : _notifiyDelegate;
            value.dereference    = tempCallback.DereferenceConnection == null ? null : _dereferenceDelegate;

            int error = Wldap32.ldap_set_option_referral(_connection.ldapHandle, LdapOption.LDAP_OPT_REFERRAL_CALLBACK, ref value);

            ErrorChecking.CheckAndSetLdapError(error);
        }
Example #9
0
 private void SetIntValueHelper(LdapOption option, int value)
 {
     if (!this.connection.disposed)
     {
         int num  = value;
         int num1 = Wldap32.ldap_set_option_int(this.connection.ldapHandle, option, ref num);
         ErrorChecking.CheckAndSetLdapError(num1);
         return;
     }
     else
     {
         throw new ObjectDisposedException(this.GetType().Name);
     }
 }
        public void FastConcurrentBind()
        {
            if (this.connection.disposed)
            {
                throw new ObjectDisposedException(base.GetType().Name);
            }
            int inValue = 1;

            this.ProtocolVersion = 3;
            int error = Wldap32.ldap_set_option_int(this.connection.ldapHandle, LdapOption.LDAP_OPT_FAST_CONCURRENT_BIND, ref inValue);

            if ((error == 0x59) && !Utility.IsWin2k3AboveOS)
            {
                throw new PlatformNotSupportedException(Res.GetString("ConcurrentBindNotSupport"));
            }
            ErrorChecking.CheckAndSetLdapError(error);
        }
Example #11
0
        public void FastConcurrentBind()
        {
            if (_connection.disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            int inValue = 1;

            // bump up the protocol version
            ProtocolVersion = 3;
            // do the fast concurrent bind
            int error = Wldap32.ldap_set_option_int(_connection.ldapHandle, LdapOption.LDAP_OPT_FAST_CONCURRENT_BIND, ref inValue);

            //we only throw PlatformNotSupportedException when we get parameter error and os is win2k3 below which does not support fast concurrent bind
            ErrorChecking.CheckAndSetLdapError(error);
        }
Example #12
0
        private void ProcessCallBackRoutine(ReferralCallback tempCallback)
        {
            QUERYFORCONNECTIONInternal    qUERYFORCONNECTIONInternal;
            NOTIFYOFNEWCONNECTIONInternal nOTIFYOFNEWCONNECTIONInternal;
            DEREFERENCECONNECTIONInternal dEREFERENCECONNECTIONInternal;
            LdapReferralCallback          ldapReferralCallback = new LdapReferralCallback();

            ldapReferralCallback.sizeofcallback = Marshal.SizeOf(typeof(LdapReferralCallback));
            LdapReferralCallback ldapReferralCallbackPointer = ldapReferralCallback;

            if (tempCallback.QueryForConnection == null)
            {
                qUERYFORCONNECTIONInternal = null;
            }
            else
            {
                qUERYFORCONNECTIONInternal = this.queryDelegate;
            }
            ldapReferralCallbackPointer.query = qUERYFORCONNECTIONInternal;
            LdapReferralCallback ldapReferralCallbackPointer1 = ldapReferralCallback;

            if (tempCallback.NotifyNewConnection == null)
            {
                nOTIFYOFNEWCONNECTIONInternal = null;
            }
            else
            {
                nOTIFYOFNEWCONNECTIONInternal = this.notifiyDelegate;
            }
            ldapReferralCallbackPointer1.notify = nOTIFYOFNEWCONNECTIONInternal;
            LdapReferralCallback ldapReferralCallbackPointer2 = ldapReferralCallback;

            if (tempCallback.DereferenceConnection == null)
            {
                dEREFERENCECONNECTIONInternal = null;
            }
            else
            {
                dEREFERENCECONNECTIONInternal = this.dereferenceDelegate;
            }
            ldapReferralCallbackPointer2.dereference = dEREFERENCECONNECTIONInternal;
            int num = Wldap32.ldap_set_option_referral(this.connection.ldapHandle, LdapOption.LDAP_OPT_REFERRAL_CALLBACK, ref ldapReferralCallback);

            ErrorChecking.CheckAndSetLdapError(num);
        }
        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);
        }
Example #14
0
 public void FastConcurrentBind()
 {
     if (!this.connection.disposed)
     {
         int num = 1;
         this.ProtocolVersion = 3;
         int num1 = Wldap32.ldap_set_option_int(this.connection.ldapHandle, LdapOption.LDAP_OPT_FAST_CONCURRENT_BIND, ref num);
         if (num1 != 89 || Utility.IsWin2k3AboveOS)
         {
             ErrorChecking.CheckAndSetLdapError(num1);
             return;
         }
         else
         {
             throw new PlatformNotSupportedException(Res.GetString("ConcurrentBindNotSupport"));
         }
     }
     else
     {
         throw new ObjectDisposedException(this.GetType().Name);
     }
 }
Example #15
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);
     }
 }