ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

Python, ADSI, COM etc



KDF

  Audi TT Stronic
Need a bit of help as my python is a bit rusty.

basically I need a script to modify a custom attribute in the active directory (ldap) schema

The custom attribute is attached to the 'person' class and is a boolean (False/True/Not Set). When the script runs it must connect to the AD via COM and modify the boolean to true.

I've done a bit of python and can display the users objects but actually modifying the attribute is proving to be a nightmare. Even a point in the right direction would be nice.

I'm using win32com.client to do the legwork if that helps.
 

sn00p

ClioSport Club Member
  A blue one.
Would IronPython not make it easier? You should be able to do it via the .NET framework and the COM ugliness goes away.
 

KDF

  Audi TT Stronic
Looks promising..

As I said I already have a script in place which reads the custom schema attribute, I just cant modify it.. i've event checked write permissions on the attribute (even although my accounts is a domain admin account)

Grr.. okay well I'll have a proper look at work tommorow !
 

KDF

  Audi TT Stronic
Hmm, it requires extra libs to run. As I need to push this out to a LOT of clients thats not an option.

I already have python plus some modules deployed. Thats why I didn't even try python-ldap.


Cheers anyway, i'll find a way to do it !
 

KDF

  Audi TT Stronic
Back of the net ;)

Code:
import active_directory

def test_ldap(username):
    u = active_directory.find_user(username)
    usercontainer = active_directory.AD_object(u.Parent)
    u.Put("eulaAccepted", False)
    u.SetInfo()
    
    return u

test_ldap(username)


Job done.. and with no extra libs :D
 


Top