<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Active Directory | DXSdata</title>
	<atom:link href="https://www.dxsdata.com/tag/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dxsdata.com</link>
	<description>Software &#124; Network &#124; Administration</description>
	<lastBuildDate>Thu, 10 May 2012 07:21:37 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://www.dxsdata.com/wp-content/uploads/2023/08/cropped-logo-32x32.jpg</url>
	<title>Active Directory | DXSdata</title>
	<link>https://www.dxsdata.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Getting user data and pictures from Active Directory</title>
		<link>https://www.dxsdata.com/2012/05/getting-user-data-and-pictures-from-active-directory/</link>
					<comments>https://www.dxsdata.com/2012/05/getting-user-data-and-pictures-from-active-directory/#respond</comments>
		
		<dc:creator><![CDATA[ds]]></dc:creator>
		<pubDate>Thu, 10 May 2012 07:21:37 +0000</pubDate>
				<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[C# .Net 2005 2008 2010]]></category>
		<category><![CDATA[Windows Server 2008 R2]]></category>
		<guid isPermaLink="false">http://dev.schausberger.cc/?p=8</guid>

					<description><![CDATA[Note: To save pictures (e.g. user photos) in AD, you can use tools like this one.]]></description>
										<content:encoded><![CDATA[<pre class="brush: csharp; title: ; notranslate">
string principal = &quot;meow&quot;; //Windows Username

string filter = string.Format(&quot;(&amp;amp;(ObjectClass={0})(sAMAccountName={1}))&quot;, &quot;person&quot;, principal);

string domain = &quot;domainname.local&quot;;

string&#x5B;] properties = new string&#x5B;] { &quot;fullname&quot; };

DirectoryEntry adRoot = new DirectoryEntry(&quot;LDAP://&quot; + domain, null, null, AuthenticationTypes.Secure);
DirectorySearcher searcher = new DirectorySearcher(adRoot);
searcher.SearchScope = SearchScope.Subtree;
searcher.ReferralChasing = ReferralChasingOption.All;
searcher.PropertiesToLoad.AddRange(properties);
searcher.Filter = filter;
SearchResult result = searcher.FindOne();
DirectoryEntry directoryEntry = result.GetDirectoryEntry();

string displayName = directoryEntry.Properties&#x5B;&quot;displayName&quot;]&#x5B;0].ToString();
string firstName = directoryEntry.Properties&#x5B;&quot;givenName&quot;]&#x5B;0].ToString();
string lastName = directoryEntry.Properties&#x5B;&quot;sn&quot;]&#x5B;0].ToString();
string email = directoryEntry.Properties&#x5B;&quot;mail&quot;]&#x5B;0].ToString();

byte &#x5B;] pic = (byte &#x5B;]) directoryEntry.Properties&#x5B;&quot;thumbnailPhoto&quot;]&#x5B;0];

MemoryStream ms = new MemoryStream(pic);

pictureBox1.Image = Image.FromStream(ms);
</pre>
<p>Note:<br />
To save pictures (e.g. user photos) in AD, you can use tools like <a href="http://blogs.msdn.com/b/croman/archive/2011/04/07/update-your-active-directory-picture-with-the-ad-photo-edit-tool.aspx">this one</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dxsdata.com/2012/05/getting-user-data-and-pictures-from-active-directory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
