Help me in making users/deleting users in active directory

Discussion in 'ASP .Net Web Controls' started by Sara rafiee, Oct 3, 2004.

  1. Sara rafiee

    Sara rafiee Guest

    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



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Sara rafiee, Oct 3, 2004
    #1
    1. Advertisements

  2. What's the error?

    --
    RobertK
    { Clever? No just smart. }

    "Sara rafiee" <> wrote in message
    news:#...
    >
    > 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
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Robert Koritnik, Oct 4, 2004
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sara rafiee
    Replies:
    3
    Views:
    1,324
    Scott Allen
    Oct 4, 2004
  2. =?Utf-8?B?SklNLkgu?=

    Q: check users in Active Directory

    =?Utf-8?B?SklNLkgu?=, Mar 21, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    643
    =?Utf-8?B?SklNLkgu?=
    Mar 21, 2005
  3. Luis Esteban Valencia

    add, delete users to an active directory?

    Luis Esteban Valencia, Jun 23, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,122
    Juan T. Llibre
    Jun 23, 2005
  4. tangus via DotNetMonster.com

    Problem retrieving Active Directory users

    tangus via DotNetMonster.com, Sep 30, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,079
    S. Justin Gengo
    Oct 1, 2005
  5. majied
    Replies:
    0
    Views:
    1,409
    majied
    Jul 15, 2005
  6. Jim in Arizona
    Replies:
    4
    Views:
    9,683
    flyby
    Dec 3, 2008
  7. rote
    Replies:
    2
    Views:
    599
  8. Wilmer Hernandez
    Replies:
    4
    Views:
    664
    Wilmer Hernandez
    Aug 20, 2007
Loading...