Help me in making users/deleting users in active directory

S

Sara rafiee

Hi there,
I need help in active directory, I want to make user in it and delete a
user, but I couldn’t. could you please help me.
as follow it is a code which should make user but it gives me error
message. pLease if anyone could correct it and send it to me.
Thanks in advance.

Regards

Sara





Public Sub Makeuser(ByVal DcDNS As String, ByVal username As String,
ByVal newPassword As String)



'Dim DcDNS As String = "bsc.aut.ac.ir" 'DcDNS use this if you
want to supply a server(name)

Dim rootDN As String

Dim ad As DirectoryEntry





ad = New DirectoryEntry(String.Format("LDAP://{0}/ad", DcDNS),
"myadminaccount", "myadmin password", AuthenticationTypes.Secure Or
AuthenticationTypes.Sealing)

rootDN = DirectCast(ad.Properties("defaultNamingContext").Value,
String)

Dim NewUser As DirectoryEntry = ad.Children.Add(username,
"user")

NewUser.Invoke("SetPassword", New Object() {newPassword})

NewUser.Invoke("Put", New Object() {"Description", "Test User
from .NET"})



NewUser.CommitChanges()

NewUser.Close()

Dim grp As DirectoryEntry



grp = ad.Children.Find("Guests", "group")

If grp.Name <> "" Then

grp.Invoke("Add", New Object() {NewUser.Path.ToString()})

End If

End Sub
 
S

Scott Allen

Hi sara:

What is the error message the code generates? What line does it happen
on? Many of the exceptions generated by AD code are security and
permissions related. If you have a permission denied exception, you
may need to run ASP.NET under a domain account instead of a local
machine account.
 
S

Sara rafiee

Hi,
thanks for your response.
yeah it says access deny, and in line invoke.commitchange
I don't know what should I do, I even used WinNT instead of that but
again this error.
what should I do???
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top