473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help me in making users/deleting users in active directory



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").V alue,
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!
Nov 18 '05 #1
3 1251
Hi sara:

What is the error message the code generates? What line does it happen
on? Many of the exceptions generated by AD code are security and
permissions related. If you have a permission denied exception, you
may need to run ASP.NET under a domain account instead of a local
machine account.

--
Scott
http://www.OdeToCode.com/

On Sun, 03 Oct 2004 00:40:47 -0700, Sara rafiee <sa********@yahoo.com>
wrote:


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").V alue,
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!


Nov 18 '05 #2
Hi,
thanks for your response.
yeah it says access deny, and in line invoke.commitchange
I don't know what should I do, I even used WinNT instead of that but
again this error.
what should I do???

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
Hi sara:

What you might want to try is impersonating a domain user in
web.config. The domain user should be an account with permissions to
delete an account in active directory.

One way to do this is to add an <indentity> elements in web.config:

<identity impersonate="true" userName ="domain\username"
password="password" />

You can read more about it here:
http://msdn.microsoft.com/library/en...ersonation.asp

--
Scott
http://www.OdeToCode.com/

On Sun, 03 Oct 2004 21:11:00 -0700, Sara rafiee <sa********@yahoo.com>
wrote:
Hi,
thanks for your response.
yeah it says access deny, and in line invoke.commitchange
I don't know what should I do, I even used WinNT instead of that but
again this error.
what should I do???

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sara | last post by:
Dear Sir, I want to access to a special group in active directory but with this function I could just see that a special user is exist in active directory or not, I mean I want to see that a user...
1
by: Amadelle | last post by:
Hi all, I am so desparately in need of some guidance! After two days of struggling I still can't connect to the Active Directory server. I have used so many different ways and so many different...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Larry Rekow | last post by:
I created a web application in classic ASP 6 months ago that had a login page which would only allow certain users to add, update or delete files from 6 different departments. (Windows 2000 server,...
3
by: Luis Esteban Valencia | last post by:
Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
0
by: Sara | last post by:
Dear Sir, I want to access to a special group in active directory but with this function I could just see that a special user is exist in active directory or not, I mean I want to see that a user...
6
by: Mr Newbie | last post by:
Hi, Im in a situation where I need to restrict users, but I dont have access or wont be allowed access to manage groups in the domain. How can I restrict access is this case ? -- Best...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.