Check if

xiaoxiao2021-03-06  16

using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls Using system.Web.ui.htmlcontrols;

Using System.directoryServices;

Namespace Test1 {///

/// WebForm2 summary description. /// public class WebForm2: System.Web.UI.Page {protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI. WebControls.TextBox textBox3; protected system.web.ui.webcontrols.button button1; private void page_load (object sender, system.eventargs e) {// Place user code here to initialize page}

#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///

/// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// private () {this.button1.click = new system.eventhandler (this.button1_click); this.load = new system.eventhandler (this.page_load);

} #Endregion

private void Button1_Click (object sender, System.EventArgs e) {this.Response.Write (IsAuthenticated (this.TextBox1.Text.ToString (), this.TextBox2.Text.ToString (), this.TextBox3.Text.ToString () ));

public bool IsAuthenticated (string domain, string username, string pwd) {string domainAndUsername = domain @ "/" username; // DirectoryEntry entry = new DirectoryEntry (_path, domainAndUsername, pwd); // DirectoryEntry entry = new DirectoryEntry ( " WinNT: // ", domainAndUsername, pwd); DirectoryEntry entry = new DirectoryEntry (" LDAP: //rl.com ", domainAndUsername, pwd); // DirectoryEntry entry = new DirectoryEntry (" LDAP: //rl.com/CN = Xuhu, CN = Users, DC = RL, DC = COM "); // DirectoryEntry Entry = New DirectoryEntry (" Winnt: // Web / Administrator "," User "); //entry.invoke ("123", "A1B2C3D4_"); //entry.commitchanges();//ldap ://rl.com/cn=xuhu ,cn=users, dc=RL, dc=com

// to-do: Need to solve the password policy problem // entry.invoke ("changePassword", new object [] {"A1B2C3D4_", "A1B2C3D_4"}; // entry.commitchanges ();

// Bind to this unit ADSObject to force authentication. Object obj = entry.nativeObject; DirectorySearcher Search = New DirectorySEARCHER (ENTRY);

Search.filter = "(SamaccountName =" UserName ")"; search.propertiestoload.Add ("cn"); searchResult result = search.findone ();

// DirectoryEntry de = new direct.path); ////De.invoke ("changePassword ", new object [] {" A1B2C3D4_ "," In4npq0umo2i "}; // de.invoke (" ChangePassword ", New Object [] {"A1B2C3D4_", "A1B2C3D4 _"}; // de.commitchanges (); /////entry.invoke ("a1b2c3d4_", "a1b2c3d5_ "); //entry.commitchanges (); //entry.commitchanges ();

If (null == result) {return false;} // update the new path of the user in the directory // _ path = result.path; // _ filterrattribute = (String) Result.properties ["cn"] [0]; / /THIS.RESPONSE.WRITE () this.path ""); this.response.write ("
"); this.Response.write (String) Result.properties ["CN" ] [0]); this.Response.write ("
"); return true;}}}}

转载请注明原文地址:https://www.9cbs.com/read-46816.html

New Post(0)