SQL Server – AD Groups and MS SQL Security: Is this a default behavior?

I have a question regarding security in the ms SQL server (for the moment, I'm trying this on a SQL 2016).

Scenario:
The AD testuser user belongs to both AD groups (AD testgroup1 and AD testgroup2).

A new testDB database is created.
A new Testtable table is created in testDB.
The connection is created for AD testgroup1
the AD testgroup1 user is created in the testDB database
The AD testgroup1 user gets select on the testTable table.

We log in as testuser, the user has only to select on TestTable -> as expected

The connection is created for AD testgroup2
the AD testgroup2 user is created in the testDB database
the AD testgroup2 user gets select, insert, update on the testTable table.

We log in as a test user, user selected, inserted, updated on TestTable -> as expected

Login AD testgroup2 is removed from the server (so AD testgroup2 remains a database usage, but the connection is removed)

We log in as a test user, the user to select, insert, update (we had the impression that this should only be selection)

access for the AD testgroup2 user is revoked in the testDB database

We log in as a test user, the user to select, insert, update (we had the impression that this should only be selection)

the AD testgroup2 user is deleted in the testDB database

We test the user, the user has to select -> as expected

Why do we still get the highest permissions even when the ad group is removed from the connections and disabled in the database users?

thank you,

Skodaddy

Apache http server – Can not connect to ftp after active SSL

I'm using Windows10, Laragon Apache & Filezilla Server for my server
it was work when my apache on http but when i turn it to https
by these codes on

    
        AllowOverride All
        Require all granted
    


    
        AllowOverride All
        Require all granted
    

    SSLEngine on
    SSLCertificateFile      C:/laragon/ssl/certificate.crt
    SSLCertificateKeyFile   C:/laragon/ssl/private.key
    SSLCertificateChainFile C:/laragon/ssl/ca_bundle.crt

my client side can not connect to the server and it does not send me any error just puts me in an endless loop try to connect

myclient (ftp-kr on vscode) result:
https://i.imgur.com/UfWQHdx.png

myserver result:
https://i.imgur.com/VeAQqUD.png

21 and 990 ports are open
I tried this with 21 and the results are the same

my client configuration

{
    "host": "95.216.111.51",
    "username": "danial",
    "password": "*******",
    "remotePath": "/",
    "protocol": "ftps",
    "port": 990,
    "fileNameEncoding": "utf8",
    "autoUpload": true,
    "autoDelete": false,
    "autoDownload": false,
    "ignore": (
        ".git",
        "/.vscode"
    )
}

my server ssl configuration filezilla linked to apache ssl certificates also
https://i.imgur.com/nrVAHiW.png

The remote SQL Server Docker connection from the IIS connection failed for the user's

I have this error when I try to connect the ASP Classic Web application (hosted in IIS 10) to SQL Server 2014 with a username and password at the same time. Using a DSN configured in the IIS docker file:

Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'

(Microsoft)(ODBC Driver 13 for SQL Server)(SQL Server)Login failed for user 'sa'.

I can login to an account using SSMS, but not from the ASP Classic Web application with the same credentials.

The environment is configured in 2 Docker containers, these are the 2 docker files:

SQL Server Docker file

FROM microsoft/windowsservercore:1803

# Download Links:
ENV exe "https://go.microsoft.com/fwlink/?linkid=840945"
ENV box "https://go.microsoft.com/fwlink/?linkid=840944"

ENV SA_PASSWORD="Password~1234" 
    attach_dbs="()" 
    ACCEPT_EULA="Y" 
    SA_PASSWORD_path="C:ProgramDataDockersecretssa-password"

SHELL ("powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';")

# make install files accessible
COPY start.ps1 /
WORKDIR /

RUN Invoke-WebRequest -Uri $env:box -OutFile SQL.box ; 
        Invoke-WebRequest -Uri $env:exe -OutFile SQL.exe ; 
        Start-Process -Wait -FilePath .SQL.exe -ArgumentList /qs, /x:setup ; 
        .setupsetup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITYNETWORK SERVICE' /SQLSYSADMINACCOUNTS='BUILTINADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; 
        Remove-Item -Recurse -Force SQL.exe, SQL.box, setup

RUN stop-service MSSQLSERVER ; 
        set-itemproperty -path 'HKLM:softwaremicrosoftmicrosoft sql servermssql14.MSSQLSERVERmssqlserversupersocketnetlibtcpipall' -name tcpdynamicports -value '' ; 
        set-itemproperty -path 'HKLM:softwaremicrosoftmicrosoft sql servermssql14.MSSQLSERVERmssqlserversupersocketnetlibtcpipall' -name tcpport -value 1433 ; 
        set-itemproperty -path 'HKLM:softwaremicrosoftmicrosoft sql servermssql14.MSSQLSERVERmssqlserver' -name LoginMode -value 2 ;

HEALTHCHECK CMD ( "sqlcmd", "-Q", "select 1" )

CMD .start -SA_PASSWORD $env:SA_PASSWORD -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs "$env:attach_dbs" -Verbose

IIS Dockerfile

FROM microsoft/iis

SHELL ("powershell", "-command")

ENV USER_NAME="iisadmin"
ENV USER_PASSWORD="Password~1234"

RUN Install-WindowsFeature Web-ASP;
RUN Install-WindowsFeature Web-CGI;
RUN Install-WindowsFeature Web-ISAPI-Ext;
RUN Install-WindowsFeature Web-ISAPI-Filter;
RUN Install-WindowsFeature Web-Includes;
RUN Install-WindowsFeature Web-HTTP-Errors;
RUN Install-WindowsFeature Web-Common-HTTP;
RUN Install-WindowsFeature Web-Performance;
RUN Install-WindowsFeature WAS;
RUN Import-module IISAdministration;

# setup Remote IIS management
RUN Install-WindowsFeature Web-Mgmt-Service; 
    New-ItemProperty -Path HKLM:softwaremicrosoftWebManagementServer -Name EnableRemoteManagement -Value 1 -Force; 
    Set-Service -Name wmsvc -StartupType automatic;

# Add user for Remote IIS Manager Login
RUN net user $env:USER_NAME $env:USER_PASSWORD /ADD; 
    net localgroup administrators $env:USER_NAME /add;

# Temporal folder for installations files
RUN md c:/msi;

RUN Invoke-WebRequest 'http://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi' -OutFile c:/msi/urlrewrite2.msi;
RUN Start-Process 'c:/msi/urlrewrite2.msi' '/qn' -PassThru | Wait-Process;

RUN Invoke-WebRequest 'https://download.microsoft.com/download/1/E/7/1E7B1181-3974-4B29-9A47-CC857B271AA2/English/X64/msodbcsql.msi' -OutFile c:/msi/msodbcsql.msi; 
RUN ("cmd", "/S", "/C", "c:\windows\syswow64\msiexec", "/i", "c:\msi\msodbcsql.msi", "IACCEPTMSODBCSQLLICENSETERMS=YES", "ADDLOCAL=ALL", "/qn");

EXPOSE 8000
RUN Remove-Website -Name 'Default Web Site';
RUN    md c:mywebsite;
RUN    New-IISSite -Name "mywebsite" -PhysicalPath 'c:mywebsite' ` -BindingInformation "*:8000:";

RUN & c:windowssystem32inetsrvappcmd.exe unlock config /section:system.webServer/asp
RUN & c:windowssystem32inetsrvappcmd.exe unlock config /section:system.webServer/handlers
RUN & c:windowssystem32inetsrvappcmd.exe unlock config /section:system.webServer/modules

RUN c:windowssystem32inetsrvappcmd.exe set config "mywebsite" -section:system.webServer/asp /scriptErrorSentToBrowser:"True"

RUN Add-OdbcDsn -Name "mywebsite" -DriverName ""ODBC Driver 13 For SQL Server"" -DsnType "System" -SetPropertyValue @(""Server=172.20.0.4"", ""Trusted_Connection=No"");

WORKDIR c:\mywebsite 

SQL Server – Query! doubt in SQLServer how to join columns with the same data types, in one

Hello! I start programming on vb.net and I have encountered a problem.

I realize a program in which I simulate three operations that generate income for me.

In the same database, I generated 3 tables (tabla1, tabla2, tabla3) and all 3 have the same columns: SERIE , OPERACION Y MONTO.
SERIES as idKey, Surgery It is a fixed datum that is different for each operation: OP1, OP2 and OP3 and the Amount What's one? decimal (10.2). Everyone has the same configuration

Now my question is, after trying the program and adding data. I expected that during the consultation in SQL (at the moment, I use the Visual Studio query generator), I run a sort of table with 3 columns with all the values ​​and at the end the sum of the amounts.

But instead, he throws me 9 columns, the 3 of each table.
and I do not know how to search this question directly on Google.

I hope you can help me, sorry if it's something simple, come learn! Thank you

web server – Mysql shut down after restarting the server

I have a 16.04 Ubuntu server with ISPConfig 3.1.

For some reason, the server was working too hard on a process with a high load, so I restarted the PC. After that, Mysql stopped working and could not be restarted.

I received these messages after trying to restart the service:

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

systemctl status mysql.service:

● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since jue 2019-08-22 18:58:05 -04; 41s ago
Docs: man:systemd-sysv-generator(8)
Process: 12020 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 12056 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

journalctl -xe:

ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x955d0c)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x93b08e)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x93cd7f)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0xa1dd9d)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0xa670b6)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x9ba375)
ago 22 18:58:32 servidor1 mysqld(12230): /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)(0x7f8ba90256ba)
ago 22 18:58:32 servidor1 mysqld(12230): x86_64/clone.S:111(clone)(0x7f8ba84cc41d)
ago 22 18:58:32 servidor1 mysqld(12230): The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
ago 22 18:58:32 servidor1 mysqld(12230): information that should help you find out what is causing the crash.


ago 22 18:58:52 servidor1 dovecot(904): auth-worker(12400): Error: sql(dmiranda@comercialkod.cl,152.172.252.195): Password query failed: Not connected to database
ago 22 18:58:52 servidor1 dovecot(904): auth: Error: auth worker: Aborted PASSV request for dmiranda@comercialkod.cl: Lookup timed out
ago 22 18:58:52 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:58:53 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:58:54 servidor1 dovecot(904): imap-login: Aborted login (auth failed, 1 attempts in 62 secs): user=, method=PLAIN, rip=152.172.252.19
ago 22 18:58:58 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:01 servidor1 CRON(12687): pam_unix(cron:session): session opened for user root by (uid=0)
ago 22 18:59:01 servidor1 CRON(12686): pam_unix(cron:session): session opened for user root by (uid=0)
ago 22 18:59:01 servidor1 CRON(12688): (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log
ago 22 18:59:01 servidor1 CRON(12689): (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.l
ago 22 18:59:01 servidor1 CRON(12686): pam_unix(cron:session): session closed for user root
ago 22 18:59:23 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:25 servidor1 su(12004): pam_unix(su:session): session closed for user root
ago 22 18:59:25 servidor1 sudo(12003): pam_unix(sudo:session): session closed for user root
ago 22 18:59:27 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:28 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:33 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:34 servidor1 sudo(12790): surempresa : TTY=pts/20 ; PWD=/home/surempresa ; USER=root ; COMMAND=/bin/su
ago 22 18:59:34 servidor1 sudo(12790): pam_unix(sudo:session): session opened for user root by (uid=0)
ago 22 18:59:34 servidor1 su(12809): Successful su for root by root
ago 22 18:59:34 servidor1 su(12809): + /dev/pts/20 root:root
ago 22 18:59:34 servidor1 su(12809): pam_unix(su:session): session opened for user root by (uid=0)
ago 22 18:59:34 servidor1 su(12809): pam_systemd(su:session): Cannot create session: Already running in a session

However, I managed to restart the service after trying the solution from this post:

https://askubuntu.com/questions/1008298/cant-start-mysql-server-database-corruption

So I put:

(mysqld)
innodb_force_recovery = 1

But it does not work well because some database tables are now read-only.

What should I do instead? Thank you.

Mysql down after restarting the server

I have a 16.04 Ubuntu server with ISPConfig 3.1.

For some reason, the server was working too hard on a process with a high load, so I restarted the PC. After that, Mysql stopped working and could not be restarted.

I received these messages after trying to restart the service:

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

systemctl status mysql.service:

● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since jue 2019-08-22 18:58:05 -04; 41s ago
Docs: man:systemd-sysv-generator(8)
Process: 12020 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 12056 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

journalctl -xe:

ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x955d0c)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x93b08e)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x93cd7f)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0xa1dd9d)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0xa670b6)
ago 22 18:58:32 servidor1 mysqld(12230): /usr/sbin/mysqld(0x9ba375)
ago 22 18:58:32 servidor1 mysqld(12230): /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)(0x7f8ba90256ba)
ago 22 18:58:32 servidor1 mysqld(12230): x86_64/clone.S:111(clone)(0x7f8ba84cc41d)
ago 22 18:58:32 servidor1 mysqld(12230): The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
ago 22 18:58:32 servidor1 mysqld(12230): information that should help you find out what is causing the crash.


ago 22 18:58:52 servidor1 dovecot(904): auth-worker(12400): Error: sql(dmiranda@comercialkod.cl,152.172.252.195): Password query failed: Not connected to database
ago 22 18:58:52 servidor1 dovecot(904): auth: Error: auth worker: Aborted PASSV request for dmiranda@comercialkod.cl: Lookup timed out
ago 22 18:58:52 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:58:53 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:58:54 servidor1 dovecot(904): imap-login: Aborted login (auth failed, 1 attempts in 62 secs): user=, method=PLAIN, rip=152.172.252.19
ago 22 18:58:58 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:01 servidor1 CRON(12687): pam_unix(cron:session): session opened for user root by (uid=0)
ago 22 18:59:01 servidor1 CRON(12686): pam_unix(cron:session): session opened for user root by (uid=0)
ago 22 18:59:01 servidor1 CRON(12688): (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log
ago 22 18:59:01 servidor1 CRON(12689): (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.l
ago 22 18:59:01 servidor1 CRON(12686): pam_unix(cron:session): session closed for user root
ago 22 18:59:23 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:25 servidor1 su(12004): pam_unix(su:session): session closed for user root
ago 22 18:59:25 servidor1 sudo(12003): pam_unix(sudo:session): session closed for user root
ago 22 18:59:27 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:28 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:33 servidor1 dovecot(904): auth-worker(12673): Error: mysql(localhost): Connect failed to database (dbispconfig): Can't connect to local MySQL server throug
ago 22 18:59:34 servidor1 sudo(12790): surempresa : TTY=pts/20 ; PWD=/home/surempresa ; USER=root ; COMMAND=/bin/su
ago 22 18:59:34 servidor1 sudo(12790): pam_unix(sudo:session): session opened for user root by (uid=0)
ago 22 18:59:34 servidor1 su(12809): Successful su for root by root
ago 22 18:59:34 servidor1 su(12809): + /dev/pts/20 root:root
ago 22 18:59:34 servidor1 su(12809): pam_unix(su:session): session opened for user root by (uid=0)
ago 22 18:59:34 servidor1 su(12809): pam_systemd(su:session): Cannot create session: Already running in a session

However, I managed to restart the service after trying the solution from this post:

Could not start MySQL server (corrupted database)

So I put:

(mysqld)
innodb_force_recovery = 1

But it does not work well because some database tables are now read-only.

What should I do instead? Thank you.

An error occurred while accessing the SharePoint site java.net.ProtocolException subsite: the server has been redirected too many times (20)

An error occurred while accessing the SharePoint site java.net.ProtocolException subsite: the server has been redirected too many times (20)

It works well when I try to load the subsite again with the same session.

It works for SharePoint on-premises 2010, but the problem only affects SharePoint on-premises 2013.

and there is only the problem to access the URL of the subsite http://schemas.microsoft.com/sharepoint/soap/GetAllSubWebCollection

Here is the error message:

(AxisFault): java.net.ProtocolException: The server has been redirected too many times (20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (native method) at sun.reflect.NativeConstructorAccessorImpl.newInstance (unknown source)
to sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Source Unknown) to java.lang.reflect.Constructor.newInstance (Source Unknown) to
sun.net.www.protocol.http.HttpURLConnection $ 6.run (Source unknown) at sun.net.protocol.http.HttpURLConnection $ 6.run (Source unknown) at java.security.AccessController.doPrivileged (Native Method) ) at sun.net.www.protocol.http.HttpURLConnection.getChainedException (Source unknown) on sun.net.protocol.http.HttpURLConnection.getInputStream (Source unknown)

want but a dedicated server with 32 GB of RAM with 16 processors

I need a dedicated server with 32 GB of RAM and 16 processors with 2 TB RAID storage with an unlimited bandwidth speed of at least 100 Mbps.

I will use it for shared hosting cpanel, so if I can get a cpanel license with an internal license for an unlimited account, it will be better. (Another provider providing unlimited cpanel for data center servers)

Thank you

Passover variable in json_value in SQL Server 2016

As answered for JSON_QUERY in this question the same is true for JSON_VALUE as well as.

Docs on JSON_VALUE

In SQL Server 2017 (14.x) and in the SQL Azure database, you can provide a
variable as the path value.

Before SQL Server 2017 you will have to build the query dynamically.


Examples

Printing the query on the SQL Server 2016

declare @id int;
set @id = 1754;

DECLARE @SQL VARCHAR(MAX);

SET @SQL ='
select 
(JSON_VALUE(cast(ad.data_map as varchar(max)),''$.dataMap."1754".value'')) CorrespondanceNumber,
(JSON_VALUE(cast(ad.data_map as varchar(max)),''$.dataMap.***"'+cast(@id as varchar(4))+'"***.value'')) Agency,
(JSON_VALUE(cast(ad.data_map as varchar(max)),''$.dataMap."1754".value'')) Protocal
from actions_new a
left join action_data ad on ad.id_ref = a.id
where baid = 32 and displayrequestid < 100;';
PRINT (@SQL);

Execution of the query on the SQL Server 2016

declare @id int;
set @id = 1754;

DECLARE @SQL NVARCHAR(MAX);
DECLARE @Parameterdefinition nvarchar(20) ='@id int';
SET @SQL ='
select 
(JSON_VALUE(cast(ad.data_map as varchar(max)),''$.dataMap."1754".value'')) CorrespondanceNumber,
(JSON_VALUE(cast(ad.data_map as varchar(max)),''$.dataMap.***"+cast(@id as varchar(4))"***.value'')) Agency,
(JSON_VALUE(cast(ad.data_map as varchar(max)),''$.dataMap."1754".value'')) Protocal
from actions_new a
left join action_data ad on ad.id_ref = a.id
where baid = 32 and displayrequestid < 100;';

EXEC SP_EXECUTESQL  
@SQL,@Parameterdefinition,@id;

DB <> violin

sharepoint online – The remote server returned an error: (401) unauthorized: when uploading the file to the document library using the application-based token authentication

I'm trying to download a document into the document library using the application-based token authentication in SharePoint Online.

I mentioned the following link to configure the application-based token and the token worked when I tried to read something on the site.

But when I try to download a file using the following code,

string file = @"Path Of the file";
System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read);
using (var ctx = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, "CLIENTID","CLIENTSECRET"))
{
    try
    {
        ctx.Load(ctx.Web, p => p.Title);
                     ctx.ExecuteQuery();
                        Console.WriteLine(ctx.Web.Title);
                     Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx, "RelativePathToDocumentLibrary" + "/test.docx", fs, false);
                }
                catch (Exception ex)
                {
                }
}

It gives me an error of

{"The remote server returned an error: (401) not allowed."}

Any suggestion or reference link is welcome.