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

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

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,057
    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:
    496
    =?Utf-8?B?SklNLkgu?=
    Mar 21, 2005
  3. Harry Barker
    Replies:
    2
    Views:
    514
    Alf P. Steinbach
    Apr 19, 2006
  4. Wilmer Hernandez
    Replies:
    4
    Views:
    459
    Wilmer Hernandez
    Aug 20, 2007
  5. crea
    Replies:
    2
    Views:
    409
    Nobody
    Dec 28, 2012
Loading...

Share This Page