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
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