简体   繁体   中英

User Authentication in indy tcp server

i am trying to write a telnet type program to read data from indy tcpserver

I want the user to first authenticate .. which is easy .. but the problem is where do I keep this authentication result so when the client executes another command, my tcpserver would know that this is an authenticated user and return data accordingly.

I hope I was specific.. and sorry for my English i'm from Venezuela.

TIdPeerThread in Indy 9, and TIdContext in Indy 10, both have a Data property that you can store whatever you want in it.

A better option is to derive a new class from TIdPeerThread / TIdServerContext instead, add your custom fields/properties to that class as needed, and then assign that class to the server's ThreadClass / ContextClass property. Each command handler can then type-cast the provided APeerThread / AContext object to your class type to access your custom data.

You should look at the source code for Indy's own components that support user authentication, such as TIdPOP3Server and TIdSMTPServer , to see how they persist authentication data between commands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM