title: Get Active Directory attributes from current domain user using LDAP
body: <p>Development Environment: 
  Windows
  some commercial useable LDAP-Client-Lib
  MinGW-gcc
  C - not C++ or C#</p>
  
  <p>i've found following LDAP-Client-Libraries and Samples: </p>
  
  <p><a href="https://www.novell.com/developer/ndk/ldap_libraries_for_c.html" rel="nofollow noreferrer">Novell OpenLDAP</a></p>
  
  <p><a href="http://fm4dd.com/programming/c-code/ad_ldaptest_c.htm" rel="nofollow noreferrer">OpenLDAP libldap</a></p>
  
  <p>The Microsoft LDAP Lib</p>
  
  <pre><code>https://msdn.microsoft.com/en-us/library/aa367033(v=vs.85).aspx
  https://msdn.microsoft.com/en-us/library/aa366102(v=vs.85).aspx
  https://msdn.microsoft.com/en-us/library/aa367016(v=vs.85).aspx
  </code></pre>
  
  <p>it needs to be C based (so i think no ADSI) 
  i need to get a list of all attributes of the current domain-user (for filtering) 
  and i have no idea where to start - im an experienced C/C++ user but never worked with AD/LDAP stuff</p>
  
  <p>thx</p>
  
  <p><strong>UPDATE #1</strong></p>
  
  <p>im able to get User and Domainname using WINAPI, find/lookup the Domain AD/LDAP-Server and can connect and retrieve some information about a user by using ldap_search_s</p>
  
  <p>i still don't fully unstand what ldap_search_s base, filter and attributes value should be to retrieve all (one level) attributes from my testuser (like first,lastname,fullname etc.)</p>
  
  <p>my current test uses this base, filter and attribute values from an example to get some (my first) results</p>
  
  <pre><code>base = "OU=Domain User,OU=TESTDOMAIN,DC=testdomain,DC=local"
  filter = "(&amp;(objectClass=user)(sAMAccountName=testuser))"
  attrs = "memberOf"
  </code></pre>
  
  <p>that gives me (i think) the groups that testuser belongs to</p>
  
  <p>im currently only got the loginname (testuser) of the user - it think that is the sAMAccountName-attribute value - so using</p>
  
  <p>CN=testuser,OU=Domain User,OU=TESTDOMAIN,DC=testdomain,DC=local</p>
  
  <p>will not(or will?) work because the CN-name ist "Test User"</p>
  
  <p><strong>UPDATE #2</strong></p>
  
  <p>the first example already solved my problem - stupid me</p>
  
  <p>so the only question is that the correct way to find user attributes?</p>
  
  <pre><code>base = "OU=Domain User,OU=TESTDOMAIN,DC=testdomain,DC=local"
  filter = "(&amp;(objectClass=user)(sAMAccountName=testuser))"
  attrs = NULL
  </code></pre>
  
  <p>or can there be problems with these base/filter kombination on other systems/konfigure-settings etc.?</p>