By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.