Thứ Bảy, 16 tháng 2, 2019

[CPANEL] Email gửi từ outlook sử dụng port 25 không được

Kiểm tra telnet port 25 tới server nếu kết nối thành công nhưng không phản hồi kết quả liền mà phải đợi 1 lúc (tầm 20s) mới có kết quả trả về thì do cơ chế chặn spam mail. Outlook hết thời gian timeout không nhận được phản hồi từ server

=> Vào WHM -> Exim Configuration -> Introduce a delay into the SMTP transaction for unknown hosts and messages detected as spam. -> set Off -> Restart Exim

Thứ Hai, 7 tháng 1, 2019

[ASP.NET][DevExpress] Exception Details: System.NotSupportedException: Collection is read-only.

Code sử dụng devexpress, chức năng upload file ảnh bị lỗi, có thông tin log error như sau
Exception Details: System.NotSupportedException: Collection is read-only.

=> Vào ISAPI Filter của site trên IIS remove 2 khai báo liên quan helicon rewrite

[ASP.NET][IIS] HttpException (0x80004005): This server variable cannot be modified during request execution

Mô tả, trang admin đăng nhập báo lỗi [HttpException (0x80004005): This server variable cannot be modified during request execution.]

Sử dụng 2 trang, trang admin (đăng nhập) gọi qua 1 trang api (web service) để chứng thực và xảy ra lỗi trên.

Nguyên nhân là do xung đột SF_NOTIFY_AUTHENTICATION event của ISAP Filter và Application_BeginRequest event trong file global.asax của source code.
(https://support.microsoft.com/en-ca/help/2605401/a-system-web-httpexception-occurs-in-internet-information-services-7-0)

=> xử lý 1 trong các cách sau

1. Site site sang pool classsic (nếu Site code tương thích)

2. phải thay đổi code

3. Site bắt buộc chạy pool integrated thì có thể remove các khai báo trong mục ISAP Filter của Site trên IIS

Thứ Năm, 30 tháng 8, 2018

[MSSQL] restricting logins to SQL Server, or limiting the number of sessions for a specific login

For example, in the following code, the logon trigger denies log in attempts to SQL Server initiated by login login_test if there are already three user sessions created by that login.

USE master;  
GO  
CREATE LOGIN login_test WITH PASSWORD = '3KHJ6dhx(0xVYsdf' MUST_CHANGE,  
    CHECK_EXPIRATION = ON;  
GO  
GRANT VIEW SERVER STATE TO login_test;  
GO  
CREATE TRIGGER connection_limit_trigger  
ON ALL SERVER WITH EXECUTE AS 'login_test'  
FOR LOGON  
AS  
BEGIN  
IF ORIGINAL_LOGIN()= 'login_test' AND  
    (SELECT COUNT(*) FROM sys.dm_exec_sessions  
            WHERE is_user_process = 1 AND  
                original_login_name = 'login_test') > 3  
    ROLLBACK;  

END;  

https://docs.microsoft.com/en-us/sql/relational-databases/triggers/logon-triggers?view=sql-server-2017

Thứ Tư, 29 tháng 8, 2018

[MSSQL] Kill Connnection to Database

=======Kill All Active Connections To A Database===
ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
   
--do you stuff here
   
ALTER DATABASE YourDatabase SET MULTI_USER


------------------or-------------------------
/*For MS SQL Server 2012 and above*/

USE [master];

DECLARE @kill varchar(8000) = '';  
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'  
FROM sys.dm_exec_sessions
WHERE database_id  = db_id('MyDB')

EXEC(@kill);

/*For MS SQL Server 2000, 2005, 2008*/

USE master;

DECLARE @kill varchar(8000); SET @kill = '';  
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), spid) + ';'  
FROM master..sysprocesses  
WHERE dbid = db_id('MyDB')

EXEC(@kill); 

------------------------------------------------
/* For a specific database */

SELECT 'KILL ' + CAST(session_id AS VARCHAR(10))
FROM sys.dm_exec_sessions
WHERE is_user_process = 1
       AND database_id = DB_ID('database name');

/* For all databases */

SELECT 'KILL ' + CAST(session_id AS VARCHAR(10))
FROM sys.dm_exec_sessions
WHERE is_user_process = 1;

=> Copy kêt quả lệnh Select và  Run

Thứ Bảy, 17 tháng 3, 2018

[CPANEL]Web HTTPS không truy cập được, HTTP thì vẫn được

Check error log

[Fri Feb 09 09:01:02.340845 2018] [ssl:error] [pid 274314:tid 140002889516800] (101)Network is unreachable: [client 157.55.39.145:12214] AH01974: could not connect to OCSP responder 'ocsp.comodoca.com'
[Fri Feb 09 09:01:02.340956 2018] [ssl:error] [pid 274314:tid 140002889516800] AH01941: stapling_renew_response: responder error

Cách fix trong trường hợp này

Edit /usr/local/apache/conf/includes/pre_virtualhost_global.conf

The same file can also be modified from WHM - Apache Include Editor

And insert :

SSLUseStapling off

Restart Apache to reload the changes :

service httpd restart

Thứ Tư, 19 tháng 7, 2017

[ASP.NET] A potentially dangerous Request.Form value was detected from the client

Lỗi này không phải do phía server mà do phía code xử lý, cụ thể lỗi xuất hiện khi post dữ liệu từ form có cấu trúc HTML lên.  đây là 1 bug trong lập trình mà hacker có thể lợi dụng để chèn code/script vào site quý khách với ý đồ xấu do đó mặc định ASP.NET sẽ không cho post dữ liệu như vậy và xuất hiện lỗi trên.

Tham khảo thông tin của bug trên tại link sau :  https://docs.microsoft.com/en-us/aspnet/whitepapers/request-validation 

Có thể tắt tính năng validate của ASP.NET để bỏ qua lỗi này, tuy nhiên việc này microsoft không khuyến cáo vì lý do nêu trên

Tham khảo disable validate trong website : https://msdn.microsoft.com/en-us/library/hh882339(v=vs.110).aspx