setting password to ADS object

  • Thread starter vishwa h via .NET 247
  • Start date
V

vishwa h via .NET 247

HI,

I am getting an error "Exception has been thrown by the target of an invocation" when I executing the following code.
User "abc" is already created under the OU(Sas).

Try
Dim myDirectoryEntry As DirectoryEntry
myDirectoryEntry = New DirectoryEntry("LDAP://myserver/CN=abc,OU=Sas,DC=com")

myDirectoryEntry.Invoke("SetPassword", "NewPassword")
myDirectoryEntry.CommitChanges()
Catch ex As Exception
MsgBox(ex.message)
End Try


any one please give suggestion about it.

(any permission we have to set in ADS/IIS)
 
P

Paul Clement

¤ HI,
¤
¤ I am getting an error "Exception has been thrown by the target of an invocation" when I executing the following code.
¤ User "abc" is already created under the OU(Sas).
¤
¤ Try
¤ Dim myDirectoryEntry As DirectoryEntry
¤ myDirectoryEntry = New DirectoryEntry("LDAP://myserver/CN=abc,OU=Sas,DC=com")
¤
¤ myDirectoryEntry.Invoke("SetPassword", "NewPassword")
¤ myDirectoryEntry.CommitChanges()
¤ Catch ex As Exception
¤ MsgBox(ex.message)
¤ End Try
¤
¤
¤ any one please give suggestion about it.
¤
¤ (any permission we have to set in ADS/IIS)

Well yes you would need permissions to reset a users password. In addition, I don't think you need
to include "myserver" in your LDAP string. Should just be user, OU container and domain.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
M

Marc Scheuner [MVP ADSI]

I am getting an error "Exception has been thrown by the target of an invocation" when I executing the following code.
User "abc" is already created under the OU(Sas).

Try
Dim myDirectoryEntry As DirectoryEntry
myDirectoryEntry = New DirectoryEntry("LDAP://myserver/CN=abc,OU=Sas,DC=com")

myDirectoryEntry.Invoke("SetPassword", "NewPassword")
myDirectoryEntry.CommitChanges()
Catch ex As Exception
MsgBox(ex.message)
End Try

Well first off - did your bind succeed ?? Can you access properties of
the "myDirectoryEntry" object? Is your LDAP bind string really
correct??

Where EXACTLY does the error occur? On the .Invoke("SetPassword",..
line, or the .CommitChanges() line?

Next: when you call SetPassword on the underlying object, you don't
need to call .CommitChanges() afterwards - the SetPassword will save
its change to the AD data store right away.

Lastly: you could try to get the ADSI native COM object for the entry,
and call .SetPassword on that interface directly (using old-style ADSI
COM calls).

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top