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
Solved

DirectoryEntry properties

Posted on 2006-11-14
5
466 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 our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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