Solved

DirectoryEntry properties

Posted on 2006-11-14
5
468 Views
Last Modified: 2010-05-18
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=employees,DC=noone,DC=gov"); //prd server

                  
DirectoryEntry container, user;
                  

container = new DirectoryEntry(strPath);
container.Username = "admin_id";
container.Password = "*admin_password";
container.AuthenticationType = AuthenticationTypes.Secure;
user = container.Children.Add("cn=" + userpin, "user");
user.Properties["sAMAccountName"].Add(alias);
user.CommitChanges();
user.Invoke("SetPassword", new object[]{password});
                  
//enable the new user
user.Properties["userAccountControl"].Value = 0x0200;
user.CommitChanges();

                              
0
Comment
Question by:Pemberley1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 13

Expert Comment

by:joechina
ID: 17940746
Sounds like your Directry Services has the setting to force users to change their password when first logon. Could you change that policy?
0
 

Author Comment

by:Pemberley1
ID: 17942295
How do you change that setting?
0
 
LVL 13

Accepted Solution

by:
joechina earned 500 total points
ID: 17947150
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question