473,396 Members | 1,779 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.

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 8153
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_directory
user = active_directory.find_user ("name-of-user")
# or user = active_directory.AD_object ("user-moniker")
user.DeleteObject (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
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 from http://techtasks.com/code/viewbookcode/1626

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

user = active_directory.find_user ("name-of-user")
# or user = active_directory.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_directory
group = active_directory.find_group ("name-of-group")
# or group = active_directory.AD_object ("group-moniker")

user = active_directory.find_user ("name-of-user")
# or user = active_directory.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
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****************************...
2
by: Annette Massie | last post by:
Is there a way to find the names of users in an Active Directory WWW group?
1
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
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...
2
by: sgr | last post by:
How do I search an user into the active directory from a c# application? Thanks for all.
4
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...
0
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...
0
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...
0
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...
0
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.