Viewing source for Recipe2001cs.aspx
<%@ Page language="c#" %>
<script runat="server">
private void Page_Load( System.object sender, System.EventArgs e) base.Load {
System.DirectoryServices.DirectoryEntry Entry = new
System.DirectoryServices.DirectoryEntry("WinNT://DomainName"); try { //Notice
that we are using the WinNT provider, if you intend to use searching. //You
must use the LDAP provider since it isn�t supported using the other providers
but we will get into that later. //Note that if you wish to get access to the
local computers accounts you would do //DomainName/ComputerName //Note that no
Login or password was set, this line would end up using the default account as
stated above. System.DirectoryServices.DirectoryEntry // Entry = new
System.DirectoryServices.DirectoryEntry("WinNT://DomainName",Login,Password)
//This will log in using the account you set. //Note you can also set the
authentication type as the 4th parameter. } catch (GAIS) { //Error message }
finally { Entry.Close(); //This will close the connection //Note that until you
try to gain access to any data you will not know if the login and password are
correct. //As will be demonstrated in the sample of how to authenticate a user.
} }
</script>