The below program written in C# which runs fine in Windows but when it comes to running in Linux ( inside a docker container) it doesn't translate the path properly.
class Program
{
static void Main(string[] args)
{
try {
bool validLogin = ValidateUser("domain", "username", "password" );
if (validLogin)
{
var path = "\\\\10.123.123.123\\folder$\\subfolder";
string fullPath = Path.Combine("\\\\10.123.123.123\\folder$\\subfolder", "file_name1");
string body = "Test File Contents";
if (!Directory.Exists(path))
{
Directory.CreateDirectory((path));
}
File.WriteAllText(fullPath, body);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString() + ex.Message);
}
}
public static bool ValidateUser(string domainName, string username, string password)
{
string userDn = $"{username}@{domainName}";
try
{
using (var connection = new LdapConnection {SecureSocketLayer = false})
{
connection.Connect(domainName, LdapConnection.DefaultPort);
connection.Bind(userDn, password);
if (connection.Bound)
return true;
}
}
catch (LdapException )
{
// Log exception
}
return false;
}
}
What exact path should I use? I have tried all sorts of combinations.