-
I try to access Windows NT username and Password for app developed in ASP.net 1.1
I want to reset the Password of users of Company 2 who are in Windows NT domain with a web application using ASP.NET 1.1 with C#.
Is the below code works fine or do I need to try some thing else, please helps me with this request.
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(&(objectClass=user)(sAMAccountName=" + UserName + "))";
deSearch.SearchScope = SearchScope.Subtree;
SearchResult results = deSearch.FindOne();
if (!(results == null))
{
de = new DirectoryEntry(results.Path);
return de;
}
else
{
return null;
}
}
/// <summary>
/// This method enables account in AD
/// </summary>
/// <param name="oDE">directoryEntry - oDE</param>
private void EnableUserAccount(DirectoryEntry oDE)
{
oDE.Properties["userAccountControl"].Value = _userStatus.Enable;
oDE.CommitChanges();
oDE.Close();
}
/// <summary>
/// This method enables resetting password on next login
/// </summary>
/// <param name="oDE">directoryEntry - oDE</param>
private void EnableResetPasswordNextLogin(DirectoryEntry oDE)
{
oDE.Properties["pwdLastSet"].Value = 0;
oDE.CommitChanges();
oDE.Close();
}
/// <summary>
/// This method resets user password
/// </summary>
/// <param name="oDE">directoryEntry - oDE</param>
/// <param name="Password">string NewPassword</param>
private void SetUserPassword (DirectoryEntry oDE, string Password)
{
object ret = oDE.Invoke("SetPassword", new object[] {Password});
}
/// <summary>
/// This method enables account in AD
/// </summary>
/// <param name="userName">string userName</param>
public void EnableUserAccount(string userName)
{
try
{
EnableUserAccount(GetUser(userName));
}
catch(Exception ex)
{
log.Error(ex);
throw;
}
}
/// <summary>
/// This method enables resetting password on next login
/// </summary>
/// <param name="userName">string username</param>
public void EnableResetPasswordNextLogin(string userName)
{
try
{
EnableResetPasswordNextLogin(GetUser(userName));
}
catch(Exception ex)
{
log.Error(ex);
}
}
/// <summary>
/// This method sets new password in AD
/// </summary>
/// <param name="userName">string Username</param>
/// <param name="newPassword">string Password</param>
public void SetPassword(string userName, string newPassword)
{
try
{
DirectoryEntry de = GetUser(userName);
SetUserPassword(de, newPassword);
de.CommitChanges();
}
catch(Exception ex)
{
log.Error(ex);
throw;
}
}
References:
Overview:
I have two companies in the Network Diagram Company one is on Windows NT 4.0 setup and Company 2 on Windows 2000 setup. The servers in company 2 are 2000 (service pack 4) using Active Directory in native mode (Not Mixed Mode) with sites/subnets/branch.
Password policy:
How many characters are required for password? (Min/Max) 8/14
Is the account reset for the user to change password at first logon? This would have to be done manually by the help desk since accounts are set to automatically lock forever.
Any complexity rules applied Not natively supported by NT 4.0 unless the SP2 passfilt.dll has been applied, which it is not.
Password age/history? Minimum password age set to 3 days, history set to remember last 5 passwords
Is it a single domain model? Yes
Similar Threads
-
By SeQuell in forum ASP.NET
Replies: 2
Last Post: 09-25-2006, 06:28 PM
-
Replies: 1
Last Post: 04-26-2005, 06:16 PM
-
By Jorge in forum VB Classic
Replies: 5
Last Post: 04-08-2002, 01:06 PM
-
By Johan in forum VB Classic
Replies: 4
Last Post: 05-04-2001, 08:23 PM
-
By Johan in forum VB Classic
Replies: 0
Last Post: 05-04-2001, 05:49 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks