Ask a Question related to ASP.NET Security, Design and Development.
-
Joe Kaplan \(MVP - ADSI\) #1
Re: Help me! How I could make user in active directory
The canonical sample is right here in the MSDN docs:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/creating_users.asp?frame=true[/url]
Note that the name of the new object must be specified as CN=TestUser1, not
TestUser1.
A couple other points:
- You don't have to use Put via Invoke with normal attribute values. You
can just set the Value property directly
- You probably need to create the object and commit it before setting the
password
- You may also need to set userAccountControl appropriately to enable it.
Joe K.
"Sara Rafiee via .NET 247" <anonymous@dotnet247.com> wrote in message
news:uRy$EGDtEHA.2804@TK2MSFTNGP14.phx.gbl...> 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 ([url]http://www.dotnet247.com/[/url])
>
> <Id>xWKmIfL0kkOgIPZLyWlpWQ==</Id>
Joe Kaplan \(MVP - ADSI\) Guest
-
Use CFLDAP to Add user onto Active Directory
How do you change a password? What I found out so far was that the password must be: - enclosed in quotes - converted to unicode then base64 -... -
Creating User Accounts with or without Active Directory
<REPOSTED> Guys, I need to build a web intranet application that can automatically create a user account when a new user registers on the... -
Creation of ASPNET user in Active Directory 203
Hello, I unable to see ASPNET user in Active directory 2003. I installed asp.net on windows 2003 & IIS. So please tell me how to create ASPNET... -
User Authentication, Active Directory and more (help)
Hi, Can a .NET application make use of the information within the Active Directory in order to Authenticate and Authorize users? For example... -
user security policy active directory
I want to apply a policy to a single user in our domain. For example, take away the run command, force background, etc. Like you could do with... -
Chris #2
Re: Help me! How I could make user in active directory
This is the easiest and most straight forward way I have seen for
communicating with Active Directory.
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/searching_with_activex_data_objects_ado.asp[/url]
And check the index on the left in MSDN. It has examples for just
about everything you need to do with Users/Groups and AD.
Chris
"Joe Kaplan \(MVP - ADSI\)" <joseph.e.kaplan@removethis.accenture.com> wrote in message news:<uOyoPNNtEHA.2956@TK2MSFTNGP12.phx.gbl>...> The canonical sample is right here in the MSDN docs:
>
> [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/creating_users.asp?frame=true[/url]
>
> Note that the name of the new object must be specified as CN=TestUser1, not
> TestUser1.
>
> A couple other points:
> - You don't have to use Put via Invoke with normal attribute values. You
> can just set the Value property directly
> - You probably need to create the object and commit it before setting the
> password
> - You may also need to set userAccountControl appropriately to enable it.
>
> Joe K.
>
> "Sara Rafiee via .NET 247" <anonymous@dotnet247.com> wrote in message
> news:uRy$EGDtEHA.2804@TK2MSFTNGP14.phx.gbl...> > 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 ([url]http://www.dotnet247.com/[/url])
> >
> > <Id>xWKmIfL0kkOgIPZLyWlpWQ==</Id>Chris Guest
-
Joe Kaplan \(MVP - ADSI\) #3
Re: Help me! How I could make user in active directory
Have you checked out all the examples in the documentation? They are pretty
helpful:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/creating_users.asp?frame=true[/url]
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.
"Sara Rafiee via .NET 247" <anonymous@dotnet247.com> wrote in message
news:eN5I0B0vEHA.2540@TK2MSFTNGP09.phx.gbl...> 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 ([url]http://www.dotnet247.com/[/url])
>
> <Id>w/HG3eHg3EaGJ5kARLMuBw==</Id>
Joe Kaplan \(MVP - ADSI\) Guest
-
Joe Kaplan \(MVP - ADSI\) #4
Re: Help me! How I could make user in active directory
A couple of things:
The user name for AD users passed to the Children.Add method must be like
("CN=TestUser1", "user")
You probably need to set sAMAccountName before you create the user
Generally, you need to do CommitChanges before you set the password for the
first time as the object won't exist yet
You also don't need to Invoke the Put method to do basic attribute setting.
Just do:
NewUser.Properties("description").Value = "Test use from .NET"
HTH,
Joe K.
"Sara Rafiee via .NET 247" <anonymous@dotnet247.com> wrote in message
news:edQs4TIzEHA.748@TK2MSFTNGP14.phx.gbl...> 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 ([url]http://www.dotnet247.com/[/url])
>
> <Id>Y5ztACux00qADznG29DELQ==</Id>
Joe Kaplan \(MVP - ADSI\) Guest
-
Patrick Olurotimi Ige #5
Re: Help me! How I could make user in active directory
Sara can u elaborate more..
What do u want to do..all i can see is that ur trying to ge to AD!
Patrick
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Patrick Olurotimi Ige Guest
-
Joe Kaplan \(MVP - ADSI\) #6
Re: Help me! How I could make user in active directory
Did you consult the samples in the SDK documentation?
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/user_management.asp?frame=true[/url]
These all work, although you may need to change the default LDAP paths to
include a server like you have in yor code below and use specific
credentials.
A couple of possible issues below are that you are trying to add a user to
the domain root instead of a specific container which may not be allowed and
is probably not a good idea. Also, you try to add the user without setting
sAMAccountName. That only works on 2003 AD, not 2000. In general, it is a
good idea to set it anyway so you don't get the default value.
You also need to set the password after you save it the first time.
If you continue to have problems, please post a stack trace of the exception
if you want better help.
Joe K.
"Sara Rafiee via .NET 247" <anonymous@dotnet247.com> wrote in message
news:Oecy6HXAFHA.3824@TK2MSFTNGP10.phx.gbl...> 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 ([url]http://www.dotnet247.com/[/url])
>
> <Id>NxbuYcXd70qD9x2YjX2JRw==</Id>
Joe Kaplan \(MVP - ADSI\) Guest



Reply With Quote

