Pemberley1
asked on
DirectoryEntry properties
I'm working with an asp.net program that was created by someone who no longer works here. It creates and sets passwords for remote access to our company's Network.I'm not very familiar with how Directry Services works either. I've researched it but can't figure this one out.
The user comes to a web page when they are internally accessing the portal on our network - a numeric id is generated for them and they set the password for use when they access they are accessing the portal externally.
The problem is that when the user creates a new accout and sets the password - it's forcing them to change the password on the next log in. Since they are setting up the password to begin with, we don't want them to have to reset it right away.
How do I set that property in my code?
The following is the code that sets up the user id & confirms the setup:
DirectoryEntry myEntry1, myEntry2;
string strPath = "LDAP://MyCompany.GOV";
// Create a 'DirectoryEntry' with the given path.
DirectoryEntry myDE = new DirectoryEntry(strPath);
myDE.Username = (@"myCompany\" + o_user);
myDE.Password = o_password;
myDE.AuthenticationType = AuthenticationTypes.Secure ;
myEntry2 = myDE.Children.Find("cn=" + o_user, "user");
//We then confirm the setup and set the password
string alias = o_pin;
string userpin = o_pin;
string password = o_password;
string strPath = ("LDAP://IP_Address/OU=emp loyees,DC= noone,DC=g ov"); //prd server
DirectoryEntry container, user;
container = new DirectoryEntry(strPath);
container.Username = "admin_id";
container.Password = "*admin_password";
container.AuthenticationTy pe = AuthenticationTypes.Secure ;
user = container.Children.Add("cn =" + userpin, "user");
user.Properties["sAMAccoun tName"].Ad d(alias);
user.CommitChanges();
user.Invoke("SetPassword", new object[]{password});
//enable the new user
user.Properties["userAccou ntControl" ].Value = 0x0200;
user.CommitChanges();
The user comes to a web page when they are internally accessing the portal on our network - a numeric id is generated for them and they set the password for use when they access they are accessing the portal externally.
The problem is that when the user creates a new accout and sets the password - it's forcing them to change the password on the next log in. Since they are setting up the password to begin with, we don't want them to have to reset it right away.
How do I set that property in my code?
The following is the code that sets up the user id & confirms the setup:
DirectoryEntry myEntry1, myEntry2;
string strPath = "LDAP://MyCompany.GOV";
// Create a 'DirectoryEntry' with the given path.
DirectoryEntry myDE = new DirectoryEntry(strPath);
myDE.Username = (@"myCompany\" + o_user);
myDE.Password = o_password;
myDE.AuthenticationType = AuthenticationTypes.Secure
myEntry2 = myDE.Children.Find("cn=" + o_user, "user");
//We then confirm the setup and set the password
string alias = o_pin;
string userpin = o_pin;
string password = o_password;
string strPath = ("LDAP://IP_Address/OU=emp
DirectoryEntry container, user;
container = new DirectoryEntry(strPath);
container.Username = "admin_id";
container.Password = "*admin_password";
container.AuthenticationTy
user = container.Children.Add("cn
user.Properties["sAMAccoun
user.CommitChanges();
user.Invoke("SetPassword",
//enable the new user
user.Properties["userAccou
user.CommitChanges();
Sounds like your Directry Services has the setting to force users to change their password when first logon. Could you change that policy?
ASKER
How do you change that setting?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.