Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Help me in making users/deleting users in active directory

Reply
Thread Tools

Help me in making users/deleting users in active directory

 
 
Sara rafiee
Guest
Posts: n/a
 
      10-03-2004

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").V alue,
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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Robert Koritnik
Guest
Posts: n/a
 
      10-04-2004
What's the error?

--
RobertK
{ Clever? No just smart. }

"Sara rafiee" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
>
> 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").V alue,
> 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
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active X Component can run Power users group but not in users grou Wilmer Hernandez ASP General 4 08-20-2007 08:36 PM
Active Directory users on Cisco PIX Diego Fernández Cisco 3 02-24-2006 09:22 AM
Q: check users in Active Directory =?Utf-8?B?SklNLkgu?= ASP .Net 4 03-21-2005 07:27 PM
Help me in making users/deleting users in active directory Sara rafiee ASP .Net 3 10-04-2004 01:35 PM
OT MMC Active Directory Users and Computers Rick MCSE 7 12-24-2003 02:01 PM



Advertisments