When I create a single LDAP ActiveDirectory user and use
DirectoryEntry. Invoke("SetPass word"...), the user is created and the
password is set with no problems.
However, when I try to add more than one user by calling my CreateUser
method repeatedly, ADSI throws an exception when I try to set the
password of the second (and all subsequent) users I create. Does
anyone have a sense of why this is happening?
The error states that one or more input parameters are invalid, but if
I restart the program and use the same parameter for the password that
raised the exception in the previous run, no exception is thrown.
For example, if I use "u1" as user name and "p1" and password name for
the first user I create, and I use "u2" and "p2" for the second user,
when I call Invoke("SetPass word", object[]{"p2"}), I get the exception
below. However, if I restart the program and use "u2" and "p2" for the
first user I create, no exception is thrown.
Here is the error thrown.
System.Reflecti on.TargetInvoca tionException: Exception has been thrown
by the target of an invocation. --->
System.Runtime. InteropServices .COMException (0x80005008): One or more
input parameters are invalid
Here is the method used to create the user.
internal void CreateUser(stri ng userName, string password)
{
//GetRootEntries( ) gets the LDAP entries in the root group to which I
am adding users.
DirectoryEntrie s entriesRoot = GetRootEntries( );
string userPathName = "cn=" + userName;
DirectoryEntry entryCheck = null;
DirectoryEntry entry = null;
try
{ // *** Seek previous entry with the same name. This
will throw an exception if user does not exist.
entryCheck = entriesRoot.Fin d(userPathName) ;
}
catch(Exception )
{
//user does not exist, which is what you want when
creating a user.
}
try
{
if ( entryCheck != null)
{
//user already exists
}
else
{
entry = entriesRoot.Add (userPathName, "user"
);
entry.Propertie s["sAMAccountName "].Add(userName);
entry.Propertie s["sn"].Add("User");
entry.Propertie s["givenName"].Add(userName);
entry.CommitCha nges();
// User has to be saved prior to this step
entry.Invoke("S etPassword", new object[]
{password} );
// Create a normal account and enable it -
ADS_UF_NORMAL_A CCOUNT; this is part of Windows SDK
(ADS_USER_FLAG_ ENUM)
// and to my knowledge, not part of .net. JL
12/18/03
entry.Propertie s["userAccountCon trol"].Value =
0x200;
entry.CommitCha nges();
entry.Close();
//cleanup; this is required for AD to store
changes fully and completely.
entry.Dispose() ;
entry = null;
}
}
catch ( Exception e2)
{
//custom error handling here...
}
entriesRoot = null;
}
}
Thanks is advance for shedding light on this,
Jessica 2 11700
Jessica,
Make sure you bind securely when calling SetPassword, something like this
should work.....
....
// re-bind using a secure authentication type when calling SetPassword
using (DirectoryEntry userEntry = new DirectoryEntry( entry.Path,
bindUser,bindPw d,
AuthenticationT ypes.Secure | AuthenticationT ypes.ServerBind ))
{
object[] password = new object[] {"somepassword" };
object ret = userEntry.Invok e("SetPassword" , password );
userEntry.Prope rties["userAccountCon trol"].Value = 0x200;
userEntry.Commi tChanges();
}
....
Willy.
"Jessica" <Je************ ***@ndchealth.c om> wrote in message
news:5d******** *************** ***@posting.goo gle.com... When I create a single LDAP ActiveDirectory user and use DirectoryEntry. Invoke("SetPass word"...), the user is created and the password is set with no problems.
However, when I try to add more than one user by calling my CreateUser method repeatedly, ADSI throws an exception when I try to set the password of the second (and all subsequent) users I create. Does anyone have a sense of why this is happening?
The error states that one or more input parameters are invalid, but if I restart the program and use the same parameter for the password that raised the exception in the previous run, no exception is thrown.
For example, if I use "u1" as user name and "p1" and password name for the first user I create, and I use "u2" and "p2" for the second user, when I call Invoke("SetPass word", object[]{"p2"}), I get the exception below. However, if I restart the program and use "u2" and "p2" for the first user I create, no exception is thrown.
Here is the error thrown.
System.Reflecti on.TargetInvoca tionException: Exception has been thrown by the target of an invocation. ---> System.Runtime. InteropServices .COMException (0x80005008): One or more input parameters are invalid
Here is the method used to create the user. internal void CreateUser(stri ng userName, string password) { //GetRootEntries( ) gets the LDAP entries in the root group to which I am adding users. DirectoryEntrie s entriesRoot = GetRootEntries( ); string userPathName = "cn=" + userName; DirectoryEntry entryCheck = null; DirectoryEntry entry = null;
try { // *** Seek previous entry with the same name. This will throw an exception if user does not exist. entryCheck = entriesRoot.Fin d(userPathName) ; } catch(Exception ) { //user does not exist, which is what you want when creating a user. } try { if ( entryCheck != null) { //user already exists } else { entry = entriesRoot.Add (userPathName, "user" );
entry.Propertie s["sAMAccountName "].Add(userName); entry.Propertie s["sn"].Add("User"); entry.Propertie s["givenName"].Add(userName); entry.CommitCha nges(); // User has to be saved prior to this step entry.Invoke("S etPassword", new object[] {password} );
// Create a normal account and enable it - ADS_UF_NORMAL_A CCOUNT; this is part of Windows SDK (ADS_USER_FLAG_ ENUM) // and to my knowledge, not part of .net. JL 12/18/03 entry.Propertie s["userAccountCon trol"].Value = 0x200; entry.CommitCha nges(); entry.Close(); //cleanup; this is required for AD to store changes fully and completely. entry.Dispose() ; entry = null;
} } catch ( Exception e2) { //custom error handling here... } entriesRoot = null; } }
Thanks is advance for shedding light on this, Jessica
Willy,
I have a few questions. How will binding securely solve
the problem I posted? Why do you think I am seeing the
error "One or more input parameters are invalid"?
Second, after you create a user and before you have set
the password, what value do you use for the password when
creating a new DirectoryEntry? I tried creating a new
DirectoryEntry as you suggested, using string.Empty as
the password, thinking this would be the correct value
before the password was ever set on the entry, but when I
tried to set the password, I got the exception "Logon
failure: unknown user name or bad password".
Thanks,
Jessica -----Original Message----- Jessica,
Make sure you bind securely when calling SetPassword,
something like thisshould work.....
.... // re-bind using a secure authentication type when
calling SetPassword using (DirectoryEntry userEntry = new DirectoryEntry
(entry.Path,bindUser,bindP wd, AuthenticationT ypes.Secure |
AuthenticationT ypes.ServerBind )) { object[] password = new object[] {"somepassword" }; object ret = userEntry.Invok e("SetPassword" ,
password ); userEntry.Prope rties["userAccountCon trol"].Value =
0x200; userEntry.Commi tChanges(); } ....
Willy.
"Jessica" <Je************ ***@ndchealth.c om> wrote in
messagenews:5d******* *************** ****@posting.go ogle.com... When I create a single LDAP ActiveDirectory user and
use DirectoryEntry. Invoke("SetPass word"...), the user is
created and the password is set with no problems.
However, when I try to add more than one user by
calling my CreateUser method repeatedly, ADSI throws an exception when I try
to set the password of the second (and all subsequent) users I
create. Does anyone have a sense of why this is happening?
The error states that one or more input parameters are
invalid, but if I restart the program and use the same parameter for
the password that raised the exception in the previous run, no exception
is thrown. For example, if I use "u1" as user name and "p1" and
password name for the first user I create, and I use "u2" and "p2" for
the second user, when I call Invoke("SetPass word", object[]{"p2"}), I
get the exception below. However, if I restart the program and use "u2"
and "p2" for the first user I create, no exception is thrown.
Here is the error thrown.
System.Reflecti on.TargetInvoca tionException: Exception
has been thrown by the target of an invocation. ---> System.Runtime. InteropServices .COMException
(0x80005008): One or more input parameters are invalid
Here is the method used to create the user. internal void CreateUser(stri ng userName, string
password) { //GetRootEntries( ) gets the LDAP entries in the root
group to which I am adding users. DirectoryEntrie s entriesRoot = GetRootEntries( ); string userPathName = "cn=" +
userName; DirectoryEntry entryCheck = null; DirectoryEntry entry = null;
try { // *** Seek previous entry with the
same name. This will throw an exception if user does not exist. entryCheck = entriesRoot.Fin d
(userPathName); } catch(Exception ) { //user does not exist, which is
what you want when creating a user. } try { if ( entryCheck != null) { //user already exists } else { entry = entriesRoot.Add
(userPathName, "user" );
entry.Propertie s["sAMAccountName "].Add(userName); entry.Propertie s["sn"].Add
("User"); entry.Propertie s
["givenName"].Add(userName); entry.CommitCha nges(); // User has to be saved prior
to this step entry.Invoke("S etPassword",
new object[] {password} );
// Create a normal account and
enable it - ADS_UF_NORMAL_A CCOUNT; this is part of Windows SDK (ADS_USER_FLAG_ ENUM) // and to my knowledge, not
part of .net. JL 12/18/03 entry.Propertie s
["userAccountCon trol"].Value = 0x200; entry.CommitCha nges(); entry.Close(); //cleanup; this is required
for AD to store changes fully and completely. entry.Dispose() ; entry = null;
} } catch ( Exception e2) { //custom error handling here... } entriesRoot = null; } }
Thanks is advance for shedding light on this, Jessica
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lekyan |
last post by:
I have problem setting the password for an ADAM user using C#. I used
the SetPassword code given in the Microsoft page, changed several
parameters, but ran into an exception. I wonder if other people have
solved this problem. But I have searched Google groups for a couple
days but still couldn't get a solution.
I copied the code from:
...
|
by: Vikash Kumar Mitruka |
last post by:
Hi,
While Invoking the SetPassword to reset the passowrkd of user in AD, i
m getting the following error
Exception Occurred at the target of Invocation
Inner Exception -- {"The network path was not found." }
A quick response will be highly obliged
|
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:
-------------------------------------------------
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x8007052E): Logon
|
by: Marek Kopanski |
last post by:
Hallo,
I have to change a user password in my ASP.NET project.
In the first step I was trying to change my own passwort (as example) in
Active Directory on my Server, but already at this point I get problems.
Can somebody help me?
1. I use following fragment of code:
-----------------------------------
DirectoryEntry DirEntry;
|
by: Mike |
last post by:
I am trying to enumerate the webs on a remote server
using the DirectoryEntry provider for VB.NET. Here is my
code:
Try
Dim SelNode As String =
TreeConfig.SelectedNode.Text
Dim oSite As New
DirectoryServices.DirectoryEntry("IIS://" & SelNode
| |
by: ABSMunkee |
last post by:
I have a vb.net dll that has two functions: one allows a user to change
their password in AD, the second allows the user to view their
distinguishedname (based on their samaccountname). Both bind via an
SSL connection and appear to work well.
I am implementing the dll through an asp interface on the DC that holds
the fsmo role of PDC in a domain with several DCs with a replication
delay of up to an hour between the DCs.
The issue I...
|
by: somebody |
last post by:
Hi there
I am using VB2005 come up with a small app to reset the user's password in
a 2000 AD. I have am able to create the user's account but all fails when I
try to set the initial password. the error I got is The filename, directory
name, or volume label syntax is incorrect. (Exception from HRESULT:
0x8007007B). when I comment out the setpassword line everthing is working
fine.
|
by: Magnus R |
last post by:
In VB.Net I'm trying to find out the names of what Administrative Groups
exist by querying Active Directory. The problem is when I try and query the
children of the key LDAP://CN=Administrative Groups, CN=ExchOrg,
CN=Microsoft Exchange, CN=Services, CN=Configuration, CN=domain, CN=com I
don't get anything except an error that the "Object doesn't exist on the
server." However when I bind to this LDAP path using LDP.exe I can see the...
|
by: Michael Howes |
last post by:
I'm writing a utility to manage a machines *local* accounts in c#
I am getting all the users in a specific Group just fine but when I
want to get some of the information on each user from their Properties
collection I can't get the properties on some users.
For example, I get all the users that are part of my machines
Administrators Group. I get get the properties of the built in local
Administrator account and some local IT account,...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |