Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > asp.net security > october 2004 >

asp.net security : Help me! How I could make user in active directory


Sara Rafiee via .NET 247
10/31/2004 3:55:00 AM
hello
can anyone help me making user in active directory , I wrote a code, but it could't work, could anyone correct it. thanks in advance.
Sub example()
'Put user code to initialize the page here
'Try
Dim AD As DirectoryEntry = _
New DirectoryEntry("LDAP://mydomian", "adminuser", "adminpassword", AuthenticationTypes.Secure Or AuthenticationTypes.Sealing)
Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
NewUser.Invoke("SetPassword", New Object() {"12345Abc"})
NewUser.Invoke("Put", New Object() {"Description", "Test User from .NET"})
NewUser.CommitChanges()
Dim grp As DirectoryEntry

grp = AD.Children.Find("Guests", "group")
If grp.Name <> "" Then
grp.Invoke("Add", New Object() {NewUser.Path.ToString()})
End If


'Catch ex As Exception
' Console.WriteLine(ex.Message)
' Console.ReadLine()
'End Try
End Sub

--------------------------------
From: Sara Rafiee

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

Joe Kaplan \(MVP - ADSI\)
10/31/2004 10:01:42 AM
Have you checked out all the examples in the documentation? They are pretty
helpful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/creating_users.asp?frame=true

Additionally, here are some things to remember:
-You probably want to create users in a more specific container than the
domain root
- You need to specify the name for the object in Children.Add(...) as
"CN=testuser1"
- If your domain is running W2K, you must set the sAMAccountName attribute
before your first commitChanges. It is also probably a good idea to do this
under 2K3 so that you get to control the logon name
- You generally need to do CommitChanges before you set the password for
the first time
- If you want the object enabled, don't forget to set userAccountControl
after you've created the object and set the password

HTH,

Joe K.

[quoted text, click to view]

AddThis Social Bookmark Button