If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > How to create new User?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-08-03, 04:37
liorlank liorlank is offline
Registered User
 
Join Date: Nov 2003
Posts: 22
How to create new User?

I need code in ASP that create user in the Active Directory Users, in order to open a mail box.

how can I do it?????
Reply With Quote
  #2 (permalink)  
Old 12-08-03, 22:40
jlot6 jlot6 is offline
Registered User
 
Join Date: Sep 2003
Location: Newark, Vermont
Posts: 20
Need a little more information then that?
Reply With Quote
  #3 (permalink)  
Old 12-09-03, 03:21
liorlank liorlank is offline
Registered User
 
Join Date: Nov 2003
Posts: 22
This is my code

Quote:
Originally posted by jlot6
Need a little more information then that?
I want to create a new User in my Active Directory

My code is
<%

%

Dim userName
Dim userPass
Dim userAcount


strName=request.form("text1")
strInitialPassword= request.form("text2")
strSAMAccountName= request.form("text3")


Dim objRootDSE
Dim objUsers
Dim objNewUser

On Error Resume Next

' Bind to the rootDSE object.

Set objRootDSE = GetObject("LDAP://rootDSE")
If (Err.Number <> 0) Then
response.write "Error1 "
End If

' Bind to the Users folder in the domain.
Set objUsers = GetObject("LDAP://CN=Users," & objRootDSE.Get("defaultNamingContext"))
If (Err.Number <> 0) Then
response.write "Error2 "
End If

' Create the user object.
Set objNewUser = objUsers.Create("user", "CN=" + strName)
If (Err.Number <> 0) Then
response.write "Error3 "
End If

' Set the sAMAccountName property.
objNewUser.Put "sAMAccountName", strSAMAccountName

If (Err.Number <> 0) Then
response.write "Error4 "
End If

' Commit the new user.
objNewUser.SetInfo
If (Err.Number <> 0) Then
response.write "Error5 "
End If

' Set the initial password. This must be done after
' SetInfo is called because the user object must
' already exist on the server.
objNewUser.SetPassword strInitialPassword
If (Err.Number <> 0) Then
response.write "Error6 "
End If

' Set the pwdLastSet property to zero, which forces the
' user to change the password at next log on.
objNewUser.Put "pwdLastSet", 0
If (Err.Number <> 0) Then
response.write "Error7 "
End If


userActCtrl = objNewUser.Get("userAccountControl")
userActCtrl = userActCtrl And Not (ADS_UF_ACCOUNTDISABLE + ADS_UF_PASSWD_NOTREQD + ADS_UF_DONT_EXPIRE_PASSWD)
objNewUser.Put "userAccountControl", userActCtrl
If (Err.Number <> 0) Then
response.write "Error8 "
End If

objNewUser.SetInfo


%>


It's print to me "Error5" What's wrong??? Untill "Error5" no problems.
How to fix it???
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On