Re: Setting a password on an AD account...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Willy,

I forgot to include the stack trace.

" at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args,
Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters)\r\n

at System.RuntimeType.InvokeMember(String name,
BindingFlags invokeAttr, Binder binder, Object target,
Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)\r\n

at System.Type.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target,
Object[] args)\r\n

at System.DirectoryServices.DirectoryEntry.Invoke
(String methodName, Object[] args)\r\n

at Project.FormName.btnCreateUser_ServerClick
(Object sender, EventArgs e) in
h:\\inetpub\\wwwroot\\Project\\secure\\FormName.aspx.cs:line 166"

Line 166 is the line where the password is set.

I hope that this helps.

"Joe" wrote:

Willy,

This is a Web App as I stated initially. The user does get created but is
disabled. No problems there.

DirectoryEntry parent = new DirectoryEntry(
"LDAP://dc.mydomain.local/OU=MyOU,DC=mydomain,DC=local";,
szUsername,
szPassword,
AuthenticationTypes.Secure);

DirectoryEntry user = parent.Children.Add("CN=" + szFName + " " + szLName,
"user");

using(user)
{
...Set properties...
user.CommitChanges();
AdsUserFlags newValue = AdsUserFlags.NormalAccount;
user.Properties["userAccountControl"].Value = newValue;
user.Invoke("SetPassword", new object[]{szPassword});
user.CommitChanges();
user.Dispose();
parent.Dispose();
}

The client is NOT a member of the domain. This code did work when it
was a Windows App.

Here are the errors:
ex.Message: Reason: Exception has been thrown by the target of an invocation.
ex.InnerException.Message: The network path was not found.

Thanks for the help.

"Joe" <Joe@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3A262B0E-81E7-437E-BEB3-3292BDEB3801@xxxxxxxxxxxxxxxx
Will,

Thanks. I am definitely connecting with AuthenticationTypes.Secure.

Could it be the level of .NET?


Guess not.
How does your objectpath looks like (LDAP://....), please specy whether the server name is a
domain name or a DC name.
Is the client (machine) a member of the AD domain you are binding to?
What's the exact callers context, is this called from a console or a Windows application or
something else?
What's the exact Exception message and if possible post a stack trace.
What happens when you don't set the password, are the objects created?

Willy.







.



Relevant Pages

  • When MailMessage.BodyFormat = MailFormat.Html, SmtpMail.Send throws exception
    ... invokeAttr, Object target, Objectargs, BooleanbyrefModifiers, ... ParameterModifiermodifiers, CultureInfo culture, String[] ... Binder binder, Object target, Objectargs) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET 2.0 with ADAM - problem
    ... An unhandled exception has occurred. ... BindingFlags invokeAttr, Object target, Objectargs, BooleanbyrefModifiers, Int32 culture, StringnamedParameters) at System.RuntimeType.InvokeMemberat System.Type.InvokeMember(String name, BindingFlags invokeAttr, ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: ASP.NET 2.0 with ADAM - problem
    ... An unhandled exception has occurred. ... BindingFlags invokeAttr, Object target, Objectargs, BooleanbyrefModifiers, Int32 culture, StringnamedParameters) at System.RuntimeType.InvokeMemberat System.Type.InvokeMember(String name, BindingFlags invokeAttr, ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Send email message with attachments

    (microsoft.public.dotnet.framework)
  • Change Password Errot IN LDAP.
    ... Int32 culture, String[] namedParameters)\r\n at ... System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, ... System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder ...
    (microsoft.public.dotnet.framework)