Server 2012 r2 denies access to Sysvol and Netlogon folder for Windows 10

While attempting to make a post request to an http server, I encountered an error when trying to obtain an input stream. To resolve this issue, I have attempted adding the necessary permissions to my manifest and creating a Network Security Config with the android:targetSandboxVersion set to 1. However, the issue persists. I would appreciate any assistance. There are a few potential solutions to this problem. One option is to use only the necessary code to make the post request. Another suggestion is to avoid the method that may result in runtime errors. The third solution involves lowering the android version to 25 in order to make the application compatible with devices running android 9 or older. It’s worth noting that the problem we are experiencing involves the inability to access the shared system folder “Netlogon & Sysvol” on the network with Windows 10 Professional operating system.


Question:

While attempting to send a post request to an http server, I encountered an issue where I received an error message

java.io.IOException: Cleartext HTTP traffic to x not permitted

when attempting to obtain an input stream.

I have attempted to incorporate

android_usesCleartextTraffic="true"

into my manifest and also created a
Network Security Config
, while setting the android:targetSandboxVersion to 1.

The XML file named “network_security_config.xml” can be found in the “app/src/main/res” directory.



    
        Server adress
    

app/src/main/AndroidManifest.xml



    
    
        
            
                
                
            
        
    

Logcat output

D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
W/System.err: java.io.IOException: Cleartext HTTP traffic to x not permitted
W/System.err:     at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:124) 
W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:248)

Any help would be appreciated


Solution 1:

Try using just

android:usesCleartextTraffic="true"

delete this 2

android:targetSandboxVersion="1"
android_networkSecurityConfig="@xml/network_security_config"

With the utilization of

android_usesCleartextTraffic="true"

, my API is capable of functioning effectively.


Solution 2:


Avoid the possibility of encountering runtime errors by refraining from doing it that way. Instead, opt for the easiest method which involves navigating to the android native project and clicking on Properties. Afterward, locate the AssemblyInfo.cs file and edit the specified section.

The application assembly includes a directive that permits the use of cleartext traffic.

example below my code:-

 using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using Android.App;
    // General Information about an assembly is controlled through the following 
    // set of attributes. Change these attribute values to modify the information
    // associated with an assembly.
    [assembly: AssemblyTitle("ZATWEBO.Android")]
    [assembly: AssemblyDescription("")]
    [assembly: AssemblyConfiguration("")]
    [assembly: AssemblyCompany("")]
    [assembly: AssemblyProduct("ZATWEBO.Android")]
    [assembly: AssemblyCopyright("Copyright ©  2014")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: ComVisible(false)]
    // Version information for an assembly consists of the following four values:
    //
    //      Major Version
    //      Minor Version 
    //      Build Number
    //      Revision
    //
    // You can specify all the values or you can default the Build and Revision Numbers 
    // by using the '*' as shown below:
    // [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyVersion("1.0.0.0")]
    [assembly: AssemblyFileVersion("1.0.0.0")]
    // Add some common permissions, these can be removed if not needed
    [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
    [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
    [assembly: Application(UsesCleartextTraffic = true)]

Only devices that have Android version 9 Pie or later are required to make this alteration.


Solution 3:


Encountering a similar issue, I resolved it by downgrading the android version to 25. As a result, the app functions efficiently on devices running android 9 or lower.



Solution 4:

When working on your local machine, it’s crucial to request 10.0.2.2 instead of localhost.

Ensure that the lines mentioned below are present in your AndroidManfest.xml file.



Your “network_security_config.xml” file should resemble the following format.



    
        
            
        
    

In case you require permitting requests to particular domains, you have the option to make changes in the “network_security_config.xml” document by using the following method:



    
        10.0.2.2
    

I have successfully tested both configurations for the network_security_config.xml file while working on my local development environment.

Frequently Asked Questions