Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

DirectoryEntry properties

Posted on 2006-11-14
5
Medium Priority
?
474 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 2000 total points
ID: 17947150
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

648 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