예제 #1
0
        void HandleRequest(object state)
        {
            // try to logon the user and create the response
            var request = (Request)state;
            int timeout;

            try { timeout = LogonAndCreateSession(request.UserName, request.Password, request.Address); }
            catch (OleDbException e)
            {
                ServiceApplication.LogEvent(EventLogEntryType.Error, e.Message);
                return;
            }
            var response = new RadiusPacket(timeout < 0 ? PacketCode.AccessReject : PacketCode.AccessAccept);

            response.Identifier = request.Identifier;
            if (timeout > 0)
            {
                response.Attribute(RadiusAttribute.SessionTimeout).Add(timeout);
            }
            response.Attribute(RadiusAttribute.ProxyState).AddRange(request.ProxyStates);
            response.SignResponse(request.Authenticator, sharedSecred);
            try { socket.SendTo(response.GetBuffer(), 0, response.Length, SocketFlags.None, request.Client); }
            catch (ObjectDisposedException) { }
            catch (SocketException e) { ServiceApplication.LogEvent(EventLogEntryType.Error, e.Message); }
        }