Skip to content

Instantly share code, notes, and snippets.

View gmackiewicz's full-sized avatar

Gabriel Mackiewicz gmackiewicz

View GitHub Profile
@ScriptingPro
ScriptingPro / PowerShell LDAP.ps1
Created January 4, 2018 22:33
LDAP bind to server/port with PowerShell using DirectoryEntry Class and query with DirectorySearcher Class
# define your query filter
$LDAPfilter = "(samaccountname=*)"
# define the object attributes you want returned
$Attributes = @"
samaccountname
givenname
surname
mail
@mrkodssldrf
mrkodssldrf / DatareaderToList
Created October 17, 2013 12:25
Convert SQL Datareader to List<T> C#
public List<T> Query<T>(string query) where T:new()
{
List<T> res = new List<T>();
MySqlCommand q = new MySqlCommand(query, this.db);
MySqlDataReader r = q.ExecuteReader();
while (r.Read())
{
T t = new T();
for (int inc = 0; inc < r.FieldCount; inc++)