Ejemplo n.º 1
0
 internal static int GetSecInfoOption(ConnectionHandle ldapHandle, LdapOption option, SecurityPackageContextConnectionInformation outValue) => Interop.Ldap.ldap_get_option_secInfo(ldapHandle, option, outValue);
Ejemplo n.º 2
0
		internal LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType, IntPtr handle)
		{
			this.connectionAuthType = AuthType.Negotiate;
			this.automaticBind = true;
			this.needDispose = true;
			this.directoryIdentifier = identifier;
			this.ldapHandle = new ConnectionHandle(handle);
			this.directoryCredential = credential;
			this.connectionAuthType = authType;
			this.options = new LdapSessionOptions(this);
			this.needDispose = false;
			this.clientCertificateRoutine = new QUERYCLIENTCERT(this.ProcessClientCertificate);
		}
Ejemplo n.º 3
0
        internal void Init()
        {
            string hostname = null;
            string[] servers = (directoryIdentifier == null ? null : ((LdapDirectoryIdentifier)directoryIdentifier).Servers);
            if (servers != null && servers.Length != 0)
            {
                StringBuilder temp = new StringBuilder(200);
                for (int i = 0; i < servers.Length; i++)
                {
                    if (servers[i] != null)
                    {
                        temp.Append(servers[i]);
                        if (i < servers.Length - 1)
                            temp.Append(" ");
                    }
                }
                if (temp.Length != 0)
                    hostname = temp.ToString();
            }

            // user wants to setup a connectionless session with server
            if (((LdapDirectoryIdentifier)directoryIdentifier).Connectionless == true)
            {
                ldapHandle = new ConnectionHandle(Wldap32.cldap_open(hostname, ((LdapDirectoryIdentifier)directoryIdentifier).PortNumber), needDispose);
            }
            else
            {
                ldapHandle = new ConnectionHandle(Wldap32.ldap_init(hostname, ((LdapDirectoryIdentifier)directoryIdentifier).PortNumber), needDispose);
            }

            // create a WeakReference object with the target of ldapHandle and put it into our handle table.
            lock (objectLock)
            {
                if (handleTable[ldapHandle.DangerousGetHandle()] != null)
                    handleTable.Remove(ldapHandle.DangerousGetHandle());

                handleTable.Add(ldapHandle.DangerousGetHandle(), new WeakReference(this));
            }
        }
Ejemplo n.º 4
0
		public static extern int ldap_bind_s(ConnectionHandle ldapHandle, string dn, SEC_WINNT_AUTH_IDENTITY_EX credentials, BindMethod method);
Ejemplo n.º 5
0
		public static extern int ldap_extended_operation(ConnectionHandle ldapHandle, string oid, berval data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
Ejemplo n.º 6
0
		public static extern int ldap_search(ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber);
Ejemplo n.º 7
0
		public static extern int ldap_set_option_referral(ConnectionHandle ldapHandle, LdapOption option, ref LdapReferralCallback outValue);
Ejemplo n.º 8
0
 internal static int ParseExtendedResult(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt) => Interop.Ldap.ldap_parse_extended_result(ldapHandle, result, ref oid, ref data, freeIt);
Ejemplo n.º 9
0
 internal static int ParseReference(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr referrals) => Interop.Ldap.ldap_parse_reference(ldapHandle, result, ref referrals);
Ejemplo n.º 10
0
 internal static IntPtr GetNextEntryFromResult(ConnectionHandle ldapHandle, IntPtr result) => Interop.Ldap.ldap_next_entry(ldapHandle, result);
Ejemplo n.º 11
0
 internal static IntPtr GetNextReferenceFromResult(ConnectionHandle ldapHandle, IntPtr result) => Interop.Ldap.ldap_next_reference(ldapHandle, result);
Ejemplo n.º 12
0
 internal static IntPtr GetNextAttributeFromResult(ConnectionHandle ldapHandle, IntPtr result, IntPtr address) => Interop.Ldap.ldap_next_attribute(ldapHandle, result, address);
Ejemplo n.º 13
0
 internal static int ModifyDirectoryEntry(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber) =>
 Interop.Ldap.ldap_modify(ldapHandle, dn, attrs, servercontrol, clientcontrol, ref messageNumber);
Ejemplo n.º 14
0
 internal static IntPtr GetValuesFromAttribute(ConnectionHandle ldapHandle, IntPtr result, string name) => Interop.Ldap.ldap_get_values_len(ldapHandle, result, name);
Ejemplo n.º 15
0
		public static extern int ldap_parse_result_referral(ConnectionHandle ldapHandle, IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt);
Ejemplo n.º 16
0
 internal static int ParseResult(ConnectionHandle ldapHandle, IntPtr result, ref int serverError, ref IntPtr dn, ref IntPtr message, ref IntPtr referral, ref IntPtr control, byte freeIt) =>
 Interop.Ldap.ldap_parse_result(ldapHandle, result, ref serverError, ref dn, ref message, ref referral, ref control, freeIt);
Ejemplo n.º 17
0
		public static extern int ldap_result(ConnectionHandle ldapHandle, int messageId, int all, LDAP_TIMEVAL timeout, ref IntPtr Mesage);
Ejemplo n.º 18
0
 internal static int ParseResultReferral(ConnectionHandle ldapHandle, IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt)
 => Interop.Ldap.ldap_parse_result_referral(ldapHandle, result, serverError, dn, message, ref referral, control, freeIt);
Ejemplo n.º 19
0
		public static extern int ldap_set_option_int(ConnectionHandle ldapHandle, LdapOption option, ref int inValue);
Ejemplo n.º 20
0
 internal static int RenameDirectoryEntry(ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber) =>
 Interop.Ldap.ldap_rename(ldapHandle, dn, newRdn, newParentDn, deleteOldRdn, servercontrol, clientcontrol, ref messageNumber);
Ejemplo n.º 21
0
		public static extern int ldap_simple_bind_s(ConnectionHandle ldapHandle, string distinguishedName, string password);
Ejemplo n.º 22
0
 internal static int GetResultFromAsyncOperation(ConnectionHandle ldapHandle, int messageId, int all, LDAP_TIMEVAL timeout, ref IntPtr Message) => Interop.Ldap.ldap_result(ldapHandle, messageId, all, timeout, ref Message);
Ejemplo n.º 23
0
		public static extern int ldap_connect(ConnectionHandle ldapHandle, LDAP_TIMEVAL timeout);
Ejemplo n.º 24
0
 internal static int ResultToErrorCode(ConnectionHandle ldapHandle, IntPtr result, int freeIt) => Interop.Ldap.ldap_result2error(ldapHandle, result, freeIt);
Ejemplo n.º 25
0
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				lock (LdapConnection.objectLock)
				{
					LdapConnection.handleTable.Remove(this.ldapHandle);
				}
			}
			if (this.needDispose && this.ldapHandle != null && !this.ldapHandle.IsInvalid)
			{
				this.ldapHandle.Dispose();
			}
			this.ldapHandle = null;
			this.disposed = true;
		}
Ejemplo n.º 26
0
 internal static int SearchDirectory(ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber) =>
 Interop.Ldap.ldap_search(ldapHandle, dn, scope, filter, attributes, attributeOnly, servercontrol, clientcontrol, timelimit, sizelimit, ref messageNumber);
Ejemplo n.º 27
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free other state (managed objects)                

                // we need to remove the handle from the handle table
                lock (objectLock)
                {
                    if (null != ldapHandle)
                    {
                        handleTable.Remove(ldapHandle.DangerousGetHandle());
                    }
                }
            }
            // free your own state (unmanaged objects)        	           

            // close the ldap connection
            if (needDispose && ldapHandle != null && !ldapHandle.IsInvalid)
                ldapHandle.Dispose();
            ldapHandle = null;

            disposed = true;

            Debug.WriteLine("Connection object is disposed\n");
        }
Ejemplo n.º 28
0
 internal static int SetClientCertOption(ConnectionHandle ldapHandle, LdapOption option, QUERYCLIENTCERT outValue) => Interop.Ldap.ldap_set_option_clientcert(ldapHandle, option, outValue);
Ejemplo n.º 29
0
 public static extern byte ldap_stop_tls(ConnectionHandle ldapHandle);
Ejemplo n.º 30
0
 internal static int SetIntOption(ConnectionHandle ld, LdapOption option, ref int inValue) => Interop.Ldap.ldap_set_option_int(ld, option, ref inValue);
Ejemplo n.º 31
0
		public static extern int ldap_parse_reference(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr referrals);
Ejemplo n.º 32
0
 internal static int SetPtrOption(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr inValue) => Interop.Ldap.ldap_set_option_ptr(ldapHandle, option, ref inValue);
Ejemplo n.º 33
0
		public static extern int ldap_rename(ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
Ejemplo n.º 34
0
 internal static int SetReferralOption(ConnectionHandle ldapHandle, LdapOption option, ref LdapReferralCallback outValue) => Interop.Ldap.ldap_set_option_referral(ldapHandle, option, ref outValue);
Ejemplo n.º 35
0
		public static extern int ldap_result2error(ConnectionHandle ldapHandle, IntPtr result, int freeIt);
Ejemplo n.º 36
0
 internal static int SetServerCertOption(ConnectionHandle ldapHandle, LdapOption option, VERIFYSERVERCERT outValue) => Interop.Ldap.ldap_set_option_servercert(ldapHandle, option, outValue);
Ejemplo n.º 37
0
		public static extern int ldap_set_option_clientcert(ConnectionHandle ldapHandle, LdapOption option, QUERYCLIENTCERT outValue);
Ejemplo n.º 38
0
 internal static void CancelDirectoryAsyncOperation(ConnectionHandle ldapHandle, int messagId) => Interop.Ldap.ldap_abandon(ldapHandle, messagId);
Ejemplo n.º 39
0
		public static extern int ldap_set_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr inValue);
Ejemplo n.º 40
0
 internal static int BindToDirectory(ConnectionHandle ld, string who, string passwd) => Interop.Ldap.ldap_simple_bind_s(ld, who, passwd);
Ejemplo n.º 41
0
		public static extern int ldap_set_option_servercert(ConnectionHandle ldapHandle, LdapOption option, VERIFYSERVERCERT outValue);
Ejemplo n.º 42
0
 internal static int StartTls(ConnectionHandle ldapHandle, ref int ServerReturnValue, ref IntPtr Message, IntPtr ServerControls, IntPtr ClientControls) => Interop.Ldap.ldap_start_tls(ldapHandle, ref ServerReturnValue, ref Message, ServerControls, ClientControls);
Ejemplo n.º 43
0
		public static extern int ldap_abandon(ConnectionHandle ldapHandle, int messagId);
Ejemplo n.º 44
0
 internal static byte StopTls(ConnectionHandle ldapHandle) => Interop.Ldap.ldap_stop_tls(ldapHandle);
Ejemplo n.º 45
0
		public static extern int ldap_compare(ConnectionHandle ldapHandle, string dn, string attributeName, string strValue, berval binaryValue, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
Ejemplo n.º 46
0
 public static extern int ldap_bind_s([In] ConnectionHandle ldapHandle, string dn, SEC_WINNT_AUTH_IDENTITY_EX credentials, BindMethod method);
Ejemplo n.º 47
0
		public static extern int ldap_delete_ext(ConnectionHandle ldapHandle, string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber);
Ejemplo n.º 48
0
 public static extern int ldap_connect([In] ConnectionHandle ldapHandle, LDAP_TIMEVAL timeout);
Ejemplo n.º 49
0
		public static extern IntPtr ldap_first_attribute(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr address);
Ejemplo n.º 50
0
 public static extern int ldap_set_option_int([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref int inValue);
Ejemplo n.º 51
0
		internal void Init()
		{
			string[] servers;
			string str = null;
			if (this.directoryIdentifier == null)
			{
				servers = null;
			}
			else
			{
				servers = ((LdapDirectoryIdentifier)this.directoryIdentifier).Servers;
			}
			string[] strArrays = servers;
			if (strArrays != null && (int)strArrays.Length != 0)
			{
				StringBuilder stringBuilder = new StringBuilder(200);
				for (int i = 0; i < (int)strArrays.Length; i++)
				{
					if (strArrays[i] != null)
					{
						stringBuilder.Append(strArrays[i]);
						if (i < (int)strArrays.Length - 1)
						{
							stringBuilder.Append(" ");
						}
					}
				}
				if (stringBuilder.Length != 0)
				{
					str = stringBuilder.ToString();
				}
			}
			if (!((LdapDirectoryIdentifier)this.directoryIdentifier).Connectionless)
			{
				this.ldapHandle = new ConnectionHandle(Wldap32.ldap_init(str, ((LdapDirectoryIdentifier)this.directoryIdentifier).PortNumber));
			}
			else
			{
				this.ldapHandle = new ConnectionHandle(Wldap32.cldap_open(str, ((LdapDirectoryIdentifier)this.directoryIdentifier).PortNumber));
			}
			lock (LdapConnection.objectLock)
			{
				if (LdapConnection.handleTable[this.ldapHandle] != null)
				{
					LdapConnection.handleTable.Remove(this.ldapHandle);
				}
				LdapConnection.handleTable.Add(this.ldapHandle, new WeakReference(this));
			}
		}
Ejemplo n.º 52
0
 public static extern int ldap_set_option_ptr([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref IntPtr inValue);
Ejemplo n.º 53
0
		private int ProcessQueryConnection(IntPtr PrimaryConnection, IntPtr ReferralFromConnection, IntPtr NewDNPtr, string HostName, int PortNumber, SEC_WINNT_AUTH_IDENTITY_EX SecAuthIdentity, Luid CurrentUserToken, ref ConnectionHandle ConnectionToUse)
		{
			ConnectionToUse = null;
			string stringUni = null;
			if (this.callbackRoutine.QueryForConnection == null)
			{
				return 1;
			}
			else
			{
				if (NewDNPtr != (IntPtr)0)
				{
					stringUni = Marshal.PtrToStringUni(NewDNPtr);
				}
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append(HostName);
				stringBuilder.Append(":");
				stringBuilder.Append(PortNumber);
				LdapDirectoryIdentifier ldapDirectoryIdentifier = new LdapDirectoryIdentifier(stringBuilder.ToString());
				NetworkCredential networkCredential = this.ProcessSecAuthIdentity(SecAuthIdentity);
				LdapConnection ldapConnection = null;
				if (ReferralFromConnection != (IntPtr)0)
				{
					lock (LdapConnection.objectLock)
					{
						WeakReference item = (WeakReference)LdapConnection.handleTable[(object)ReferralFromConnection];
						if (item == null || !item.IsAlive)
						{
							if (item != null)
							{
								LdapConnection.handleTable.Remove(ReferralFromConnection);
							}
							ldapConnection = new LdapConnection((LdapDirectoryIdentifier)this.connection.Directory, this.connection.GetCredential(), this.connection.AuthType, ReferralFromConnection);
							LdapConnection.handleTable.Add(ReferralFromConnection, new WeakReference(ldapConnection));
						}
						else
						{
							ldapConnection = (LdapConnection)item.Target;
						}
					}
				}
				long lowPart = (long)CurrentUserToken.LowPart + ((long)CurrentUserToken.HighPart << 32);
				LdapConnection queryForConnection = this.callbackRoutine.QueryForConnection(this.connection, ldapConnection, stringUni, ldapDirectoryIdentifier, networkCredential, lowPart);
				if (queryForConnection != null)
				{
					ConnectionToUse = queryForConnection.ldapHandle;
				}
				return 0;
			}
		}
Ejemplo n.º 54
0
 public static extern int ldap_get_option_sechandle([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref SecurityHandle outValue);
Ejemplo n.º 55
0
 internal LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType, IntPtr handle)
 {
     directoryIdentifier = identifier;
     needDispose = false;
     ldapHandle = new ConnectionHandle(handle, needDispose);
     directoryCredential = credential;
     _connectionAuthType = authType;
     _options = new LdapSessionOptions(this);
     clientCertificateRoutine = new QUERYCLIENTCERT(ProcessClientCertificate);
 }
Ejemplo n.º 56
0
 public static extern int ldap_get_option_secInfo([In] ConnectionHandle ldapHandle, [In] LdapOption option, [In, Out] SecurityPackageContextConnectionInformation outValue);
Ejemplo n.º 57
0
 public static extern int ldap_start_tls(ConnectionHandle ldapHandle, ref int ServerReturnValue, ref IntPtr Message, IntPtr ServerControls, IntPtr ClientControls);
Ejemplo n.º 58
0
		public static extern int ldap_parse_extended_result(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt);
Ejemplo n.º 59
0
 public static extern int ldap_create_sort_control(ConnectionHandle handle, IntPtr keys, byte critical, ref IntPtr control);
Ejemplo n.º 60
0
 internal static int GetSecurityHandleOption(ConnectionHandle ldapHandle, LdapOption option, ref SecurityHandle outValue) => Interop.Ldap.ldap_get_option_sechandle(ldapHandle, option, ref outValue);