Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Security / November 2005

Tip: Looking for answers? Try searching our database.

ADSI - Adding a user and enabling them (can add can't enable)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeremie Legault - 23 Nov 2005 21:19 GMT
Hi,

I have written an ASP.NET 2.0 application that uses Active Directory or ADAM
to manage account users - the site has a page that allows people to create an
account (much like any site). The page populates the AD with all the
information and the user account but I am unable to enable the account.
Microsoft has information on how to do that here -->
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/example_c
ode_for_creating_a_user.asp

(the sample is for Visual Basic) - and I am unable to complete the bottom
portion of the script. Can some one point me in the right direction - or can
you tell me how I can add a snippet of VBscript code to an ASP.NET page.

I am using the Active DS Type library - not sure why there are multiple ones
(System.DirectoryServices) but it is rather confusing - I seem to accomplish
one thing with one and another with the other (they did have trouble
co-existing however). Anyway my script works very well but I am not able to
access the properties required to enable the account.

Here is a simple version (no error checking) of the code
   Sub BTSub_Click(ByVal sender As Object, ByVal e As EventArgs)
       Dim objUsers As ActiveDs.IADsContainer
       Dim objNewUser As ActiveDs.IADsUser
       objUsers = GetObject("LDAP://OU=Pickupfootball,DC=systemfix,DC=ca")
       objNewUser = objUsers.Create("user", "CN=" & txtFName.Text &
txtLName.Text)
       objNewUser.Put("sAMAccountName", txtFName.Text & txtLName.Text)
       objNewUser.Put("givenName", txtFName.Text)
       objNewUser.Put("sn", txtLName.Text)
       objNewUser.Put("streetAddress", txtEADDR.Text)
       objNewUser.Put("mail", txtEADDR.Text)
       objNewUser.Put("title", txtOCC.Text)
       objNewUser.Put("displayName", txtFName.Text & "." & txtLName.Text)
       objNewUser.Put("description", GNDList.Text & ";" & txtAge.Text)
       objNewUser.SetInfo()
       objNewUser.ChangePassword("", "j1r1mi1")
       
   End Sub

One other thought I had is maybe I can run a VBscript from within the page
after the user is added - is that possible? If so how can I do that?

Thanks
Jeremie Legault
jlegault@systemfix.ca
Joe Kaplan (MVP - ADSI) - 24 Nov 2005 03:21 GMT
You multi-posted.  I answered in a different group.

Joe K.

> Hi,
>
[quoted text clipped - 46 lines]
> Jeremie Legault
> jlegault@systemfix.ca

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.