473,809 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory: how to delete a user from a group?

Hi!

Does anyone has experience with manipulating MS Active Directory
objects? I'd like to delete some users from a group, but so far I
couldn't find anything about this.
There is some good stuff about retrieving data out of the AD (thanks
to Tim Golden!), but how can I manipulate or change AD objects like
users, computers and groups with Python? Is there somewhere a
documentation or some code?

Dirk

May 2 '07 #1
3 8187
Dirk Hagemann wrote:
Hi!

Does anyone has experience with manipulating MS Active Directory
objects? I'd like to delete some users from a group, but so far I
couldn't find anything about this.
There is some good stuff about retrieving data out of the AD (thanks
to Tim Golden!), but how can I manipulate or change AD objects like
users, computers and groups with Python? Is there somewhere a
documentation or some code?
I freely admit I don't do too much changing of AD objects,
but my module should at least support the methods for doing
things. Some examples in Active Directory Cookbook:

http://techtasks.com/code/viewbook/2

To delete a user, apparently:

<code>
import active_director y
user = active_director y.find_user ("name-of-user")
# or user = active_director y.AD_object ("user-moniker")
user.DeleteObje ct (0)
</code>

TJG
May 2 '07 #2
Tim Golden wrote:
Dirk Hagemann wrote:
>Hi!

Does anyone has experience with manipulating MS Active Directory
objects? I'd like to delete some users from a group, but so far I
couldn't find anything about this.
There is some good stuff about retrieving data out of the AD (thanks
to Tim Golden!), but how can I manipulate or change AD objects like
users, computers and groups with Python? Is there somewhere a
documentatio n or some code?

I freely admit I don't do too much changing of AD objects,
but my module should at least support the methods for doing
things. Some examples in Active Directory Cookbook:

http://techtasks.com/code/viewbook/2
Sorry, you wanted to remove a user *from a group*. Misread.

Translated from http://techtasks.com/code/viewbookcode/1626

<code>
import active_director y
group = active_director y.find_group ("name-of-group")
# or group = active_director y.AD_object ("group-moniker")

user = active_director y.find_user ("name-of-user")
# or user = active_director y.AD_object ("user-moniker")

group.Remove (user.path ())

</code>

Obviously, for something this simple using an extra module
is overkill. You might as well:

<code>
import win32com.client

group = win32com.client .GetObject ("group-moniker")
group.Remove ("user-moniker")

</code>

NB I haven't tried these, I've just translated them
from the Cookbook site!

TJG
May 2 '07 #3
On 2 Mai, 17:48, Tim Golden <m...@timgolden .me.ukwrote:
Tim Golden wrote:
Dirk Hagemannwrote:
Hi!
Does anyone has experience with manipulating MS Active Directory
objects? I'd like to delete some users from a group, but so far I
couldn't find anything about this.
There is some good stuff about retrieving data out of the AD (thanks
to Tim Golden!), but how can I manipulate or change AD objects like
users, computers and groups with Python? Is there somewhere a
documentation or some code?
I freely admit I don't do too much changing of AD objects,
but my module should at least support the methods for doing
things. Some examples in Active Directory Cookbook:
http://techtasks.com/code/viewbook/2

Sorry, you wanted to remove a user *from a group*. Misread.

Translated fromhttp://techtasks.com/code/viewbookcode/1626

<code>
import active_director y
group = active_director y.find_group ("name-of-group")
# or group = active_director y.AD_object ("group-moniker")

user = active_director y.find_user ("name-of-user")
# or user = active_director y.AD_object ("user-moniker")

group.Remove (user.path ())

</code>

Obviously, for something this simple using an extra module
is overkill. You might as well:

<code>
import win32com.client

group = win32com.client .GetObject ("group-moniker")
group.Remove ("user-moniker")

</code>

NB I haven't tried these, I've just translated them
from the Cookbook site!

TJG
Hi Tim!

The first code does exactly what I want - thanks a lot again for your
help.

Dirk

May 4 '07 #4

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

Similar topics

1
3049
by: Publickey | last post by:
Hi, I am having trouble setting the user's cn value using VB .NET 2002 while creating a new user account. The code is as below: ***********************Start of code**************************** Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://" + ldapStr) Dim NewUser As DirectoryEntry = enTry.Children.Add("CN=" & sAMAccountName, "User") NewUser.Properties("sAMAccountName").Value = sAMAccountName...
2
4396
by: Annette Massie | last post by:
Is there a way to find the names of users in an Active Directory WWW group?
1
1931
by: mg | last post by:
Can someone give me C# code that will connect me to Active Directory, let me give Active Directory a user's name and retrieve his/her e-mail address. I need this for a WebForm.
3
2333
by: Gentian Hila | last post by:
Hello there, I was wondering if any one knows some good source, book, or even MSDN resurce (I found something there, but seems to be very little) that instructs how to create in VB.NET programs for Active Directory (adding user, creating folder, changing permissions, creating exchange mailboxes). I have done some user, home folder, mailbox creation in VBScript, but now I am planning to do a GUI program in VB.NET that does basically the...
2
1868
by: sgr | last post by:
How do I search an user into the active directory from a c# application? Thanks for all.
4
10930
by: cpajoe2001 | last post by:
I am not sure if this is the proper place to put this thread but I have run into a road block. I am writing a web app that will create groups in Active Directory then add users to those groups. I have it creating the groups just fine however when i go to add a user i get. The requested operation did not satisfy one or more constraints associated with the class of the object. (Exception from HRESULT: 0x80072014) And I can not find any help on...
0
4160
by: justintaitt | last post by:
Hi, I am new to active directory and am trying to query it for the user name and ID of members of a group to populate a drop down list in the form: firstname lastname (userID) When I run the page which calls this function through visual studio it works fine and the drop down list is populated. However when I run the page over the intranet I get this error. Unknown error (0x8000500c) Description: An unhandled exception occurred during the...
0
1339
by: Phylum | last post by:
Hi all. Just signed up today and I was hoping to simplify a task I'm sure we may all benefit from. I thank you in advance for clicking on this post! I want to warn you that I'm no coding guru - I apologize for that. I'm hoping I some one could assist me in the creation of a saved query in AD that would report all users in group X. From time to time it would be nice to see what users are members of certain groups. Going to the group and...
0
1081
by: VBDevo | last post by:
Hello, Can anyone help me in this please I'm trying to restore an Active Directory deleted user, I found the code only in c++ in the MSDN, and it uses the DLL : wldap32.dll , which is under system32 in windows , but when I try to add reference it gives me an error that the assembly is not valid. would you tell me how should I use it , or how should I use the LDAPControl or how can we restore an AD object in vb.net please Thank you
0
1208
by: s_erez | last post by:
Hi, I have an active directory group which I need to get a list of all groups it is a member of, using a C# code. I know how to do this for a user, however i have a problem getting this list for a group. Any suggestions? Erez.
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10633
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.