Files
codeql/csharp/ql/test/query-tests/Security Features/CWE-090/StoredLDAPInjection.cs
2021-07-01 16:09:11 +02:00

29 lines
823 B
C#

using System;
using System.Data.SqlClient;
using System.DirectoryServices;
namespace Test
{
class StoredLDAPInjection
{
public void processRequest()
{
using (SqlConnection connection = new SqlConnection(""))
{
connection.Open();
SqlCommand customerCommand = new SqlCommand("SELECT * FROM customers", connection);
SqlDataReader customerReader = customerCommand.ExecuteReader();
while (customerReader.Read())
{
// BAD: Read from database, write it straight to a response
DirectorySearcher ds = new DirectorySearcher("accountname=" + customerReader.GetString(1));
}
customerReader.Close();
}
}
}
}