Solved

DirectoryEntry properties

Posted on 2006-11-14
5
464 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
display data in text field from data base for updating 6 50
Make all values in arrayist to titlecase+vb.net 23 27
Linq Help 1 34
C# Offline Apllication 5 51
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now