473,414 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

LDAP SetPassword Exception help

I have a website with a page that is an AD interface. We use it to
create/edit AD users.

This webpage code was working fine. Then we upgraded our 2003 SP1 PDC
hardware. In a nutshell... a new windows 2003 SP1 server box, promoted to
DC (it replicates AD from the existing PDC). Then allow the Global Catalog
to replicate to the new DC, and then have it seize the FSMO roles from the
existing PDC. The role xfer effectively demotes the 'old' PDC to a normal
DC, and the new DC to the PDC. Demote the old DC to a Workstation &
eventually removed it from the network, renamed the new PDC & change IP to
mimic the old one. Long story short, connecting clients don't realize
anything has changed. That was the plan anyway.

There's obviously a subtle difference somewhere, because here is the code
from my AD interface page that stopped working right after the server
upgrade/switch. It's when we create a new user and set the initial
password:

===============================

Private Function CreateADSAccount(ByVal strUserName As String, ByVal
strDisplayName As String, ByVal strEmailAddress As String) As String

Dim objADS As DirectoryServices.DirectoryEntry
Dim objNewUser As DirectoryServices.DirectoryEntry
Dim objGroup As DirectoryServices.DirectoryEntry
Dim objGetAccountDisabled As Object

Try

objADS = New
DirectoryServices.DirectoryEntry(ConfigurationSett ings.AppSettings.Item("ldapConnectionString"),
_
ConfigurationSettings.AppSettings.Item("theKeymake rUser"), _
ConfigurationSettings.AppSettings.Item("theKeymake rUserPassword"), _
DirectoryServices.AuthenticationTypes.ServerBind)

'Add a new user
objNewUser = objADS.Children.Add("cn=" & strUserName, "user")

'Commit
objNewUser.CommitChanges()

'Change properties
objNewUser.Properties("samAccountName").Value = strUserName
objNewUser.Properties("displayName").Value = strDisplayName

'See
http://msdn.microsoft.com/library/de...untcontrol.asp
'for descriptions of userAccountControlValues.
'Here, we're setting the account to Normal (i.e., not Disabled) and
forcing a password expiration.
objNewUser.Properties("userAccountControl").Value = &H200
objNewUser.Properties("pwdLastSet").Value = 0

'Commit
objNewUser.CommitChanges()

'Set the new password
'Make a new random password that the user will have to change when they
first logon
strPassword = Me.MiscTools.randomString()

objNewUser.Invoke("SetPassword", New Object() {strPassword})
....
===============================

That last line where I invoke SetPassword was working fine against the
previous server. Against the new server, it's now throwing this exception:

"One or more input parameters are invalid"

I've read about how you need a secure connection to AD in order to set
passwords. This is the code I used to set passwords against the old server,
but the old PDC was an enterprise CA. So, guessing, I installed cert
services on the new PDC (as enterprise CA). SetPassword throws the same
error. I tried using SSL and/or Secure flags when defining objADS (instead
of just ServerBind). Still errors, but a different error:

"Access is denied."

I know the user being referenced in appConfig is an Administrator and I know
it's creds are valid.

I can invoke *change* password on *existing* users... that code still works
fine. It's SetPassword for brand new users that fails. I have verified the
passwords being returned from randomString() are valid passwords for AD's
current password policy.

Anyone have any idea on this?
Aug 29 '06 #1
0 1520

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Amar | last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap does not have security as it returns only user demographic information. i do not need to bind with a username or...
0
by: Pedro CLIKEAR | last post by:
The problem happens when we try to set the password for two different users with DirectoryEntry.Invoke method. The first time we use user.Invoke("SetPassword",new object {pwdUsuario}); it works...
5
by: Ram | last post by:
Hey, I'v managed to set the "User Must Change Password At Next Logon" flag on the LDAP protocol, Using the - "pwdLastSet" property - by setting it to - "0" (for on) or - "-1" (for off). The...
3
by: Jay | last post by:
I have a simple LDAP query (grabs all users from a particular AD group and populates a checkboxlist) that works perfectly fine on the development machine logged on locally as any user. When I...
2
by: knea | last post by:
Hi, I noticed a bunch of postings about getting error while invoking the "setPassword" method. I am getting similar error and any help would be appreciated. The error that I am getting is: ...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
2
by: Jay | last post by:
Hi, This is Jay Mehta. I have this problem when using LDAP. I extract names and EmailId's of all those present from LDAP and populate in a datagrid. Now when run locally, it is running...
0
by: Pulak Kumar Mishra | last post by:
When Change password using SetPassword option. an exception occur and not update password of login.
3
by: martybruce | last post by:
I have some VB.net code. Basically when the user logs into the app. It checks to see if the user's AD account password has expired. If so, It will prompt the user to change it. mydn =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.