Thứ Bảy, 20 tháng 4, 2019

[ASP.NET] Lỗi liên quan SQL CLR , khi move DB qua server mới web không chạy

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'groupconcat, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A

loging in with sa, restoring DB again and setting TRUSTWORTHY ON

USE [apel_vn_db];
EXEC sp_configure 'clr enabled' ,1
GO

USE [apel_vn_db];
GO

EXEC sp_changedbowner 'sa'
USE [apel_vn_db];
GO

ALTER DATABASE [apel_vn_db] SET TRUSTWORTHY ON;

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