Solved

DirectoryEntry properties

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

11 Experts available now in Live!

Get 1:1 Help Now