Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Absolutely. This is especially useful for intranet applications.</p> <p>Since you did not specify your environment, I'll assume it is .NET, but that isn't the only way possible of course.</p> <p>Active Directory can be queried easily using <a href="http://en.wikipedia.org/wiki/LDAP" rel="nofollow noreferrer">LDAP</a>. If you're using .NET, you can do something like in <a href="http://www.codeproject.com/KB/system/QueryADwithDotNet.aspx" rel="nofollow noreferrer">this code example</a> or my example below. You can also do it within <a href="https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-22_11-5259887.html" rel="nofollow noreferrer">SQL environments</a> as well.</p> <p>If you just need Windows to handle authentication, you can set, for example, a .NET Web app up for <a href="http://weblogs.asp.net/scottgu/archive/2006/07/12/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application.aspx" rel="nofollow noreferrer">Windows Authentication</a>. Be sure to <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/524404dc-8586-46b0-89ac-0f5db6d33c9c.mspx?mfr=true" rel="nofollow noreferrer"><strong>turn off Anonymous Logins</strong></a> within IIS for your application. Once done, you'll be able to access the user's Windows logon name and use it to make further security checks (for example, their <a href="http://msdn.microsoft.com/en-us/library/4z6b5d42.aspx" rel="nofollow noreferrer">group/role membership</a> in AD).</p> <p>You can also simplify the whole mess using something like Enterprise Library's <a href="http://msdn.microsoft.com/en-us/library/cc309291.aspx" rel="nofollow noreferrer">Security Application Block</a>.</p> <hr> <p>Here is a short C# example: (convert to VB.NET <a href="http://www.developerfusion.com/tools/convert/csharp-to-vb/" rel="nofollow noreferrer">here</a>)</p> <pre><code>using System.DirectoryServices; /// &lt;summary&gt; /// Gets the email address, if defined, of a user from Active Directory. /// &lt;/summary&gt; /// &lt;param name="userid"&gt;The userid of the user in question. Make /// sure the domain has been stripped first!&lt;/param&gt; /// &lt;returns&gt;A string containing the user's email address, or null /// if one was not defined or found.&lt;/returns&gt; public static string GetEmail(string userid) { DirectorySearcher searcher; SearchResult result; string email; // Check first if there is a slash in the userid // If there is, domain has not been stripped if (!userid.Contains("\\")) { searcher = new DirectorySearcher(); searcher.Filter = String.Format("(SAMAccountName={0})", userid); searcher.PropertiesToLoad.Add("mail"); result = searcher.FindOne(); if (result != null) { email = result.Properties["mail"][0].ToString(); } } return email; } </code></pre> <p>You do not have to specify a domain controller. Performing the empty/default constructor for DirectorySearcher will cause it to attempt to look one up automatically &mdash; in fact, this is <a href="http://weblogs.asp.net/steveschofield/archive/2004/04/28/121857.aspx" rel="nofollow noreferrer"><strong>the preferred method</strong></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload