Hello All,
I am struggling with some ldap files.
I am using the csv module to work with this files (I exported the ldap
to a csv file).
I have this string on a field
CN=pointhairedp eoplethatsux,OU =Groups,OU=Hate people,OU=HR,DC =fabrika,DC=com ;CN=pointhaired boss,OU=Groups, OU=Hatepeople,O U=HR,DC=fabrika ,DC=com
this string is all the groups one user has membership.
So what I am trying to do.
read this string
and extract only the CNs
like
pointhairdepeop lethatsux,point hairedboss
Or think in negative way
remove the OU=****** and DC= ******
Any ideas? 3 2380
I have this string on a field
CN=pointhairedp eoplethatsux,OU =Groups,OU=Hate people,OU=HR,DC =fabrika,DC=com ;CN=pointhaired boss,OU=Groups, OU=Hatepeople,O U=HR,DC=fabrika ,DC=com
this string is all the groups one user has membership.
So what I am trying to do.
read this string
and extract only the CNs
like
pointhairdepeop lethatsux,point hairedboss
>>s =
"CN=pointhaired peoplethatsux,O U=Groups,OU=Hat epeople,OU=HR,D C=fabrika,DC=co m;CN=pointhaire dboss,OU=Groups ,OU=Hatepeople, OU=HR,DC=fabrik a,DC=com"
>>pieces = sum([p.split(';') for p in s.split(',')], []) pieces
['CN=pointhaired peoplethatsux', 'OU=Groups', 'OU=Hatepeople' ,
'OU=HR', 'DC=fabrika', 'DC=com', 'CN=pointhaired boss',
'OU=Groups', 'OU=Hatepeople' , 'OU=HR', 'DC=fabrika', 'DC=com']
>>pieces = sum([p.split(';') for p in s.split(',')], []) cns = [piece[3:] for piece in pieces if piece.startswit h('CN=')] cns
['pointhairedpeo plethatsux', 'pointhairedbos s']
The process basically splits on commas, then splits each of those
pieces on semi-colons, then flattens the list-of-lists into a
single list of all the pieces (the flattening is done by abusing
sum() so there may be better, more elegant ways of doing that).
Once you have the flattened list of pieces, you can then just
check for the ones that start with "CN=" and extract the bits of
them that you need.
-tkc
>I have this string on a field
>CN=pointhaired peoplethatsux,O U=Groups,OU=Hat epeople,OU=HR,D C=fabrika,DC=co m;CN=pointhaire dboss,OU=Groups ,OU=Hatepeople, OU=HR,DC=fabrik a,DC=com this string is all the groups one user has membership. So what I am trying to do. read this string and extract only the CNs
like
pointhairdepeo plethatsux,poin thairedboss
>>s =
"CN=pointhaired peoplethatsux,O U=Groups,OU=Hat epeople,OU=HR,D C=fabrika,DC=co m;CN=pointhaire dboss,OU=Groups ,OU=Hatepeople, OU=HR,DC=fabrik a,DC=com"
Or, if you're a regexp junkie...
>>import re r = re.compile('CN= ([^;,]*)') r.findall(s )
['pointhairedpeo plethatsux', 'pointhairedbos s']
I'll leave timing comparisons as an exercise to the reader... ;)
Both of these solutions make the assumption that neither a comma
nor a semicolon are permissible in a CN.
-tkc
flit wrote:
>
I am struggling with some ldap files.
More general you are struggling with multiple attribute values of DN
syntax stored in a single field of a CSV file.
I am using the csv module to work with this files (I exported the ldap
to a csv file).
I guess you have MS AD and used MS tools for CSV export.
I have this string on a field
CN=pointhairedp eoplethatsux,OU =Groups,OU=Hate people,OU=HR,DC =fabrika,DC=com ;CN=pointhaired boss,OU=Groups, OU=Hatepeople,O U=HR,DC=fabrika ,DC=com
this string is all the groups one user has membership.
It seems they are using ; as a delimiter for multi-valued attributes in
a single CSV field. Note that ; is also a special character for
LDAPv2-DNs. So a naive parsing will fail under special circumstances.
I'd recommend to export your data as LDIF and use the module 'ldif' from
python-ldap to extract the entry records. You can use this module
separately simply by placing the file ldif.py under site-packages/ if
you don't need the rest of python-ldap.
So what I am trying to do.
read this string
and extract only the CNs
This is another issue.
Note that in general DN parsing is more complex than simply using
string.split(). If you are sure that all the attribute values used in
your DNs don't have any special chars you could use string.split(). But
you should definitely cross-check with RFC 4514 or use a decent DN parser.
Ciao, Michael. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Willis Lang |
last post by:
I'm getting Access Denied error. I've had this for oci8 and I fixed it by
giving IUSER read access to the entire oracle directory. For the ldap
problem, I've put the ssleay and the libeay dlls into the system32
directory. IUSER has read access to the system32 directory as well as all
files and folders in my php directory. I'm wondering if there are other
files out there that ldap may need. Or is there some sort of permission I
need to...
|
by: Joe User |
last post by:
I have a set of web pages on an AD-authenticated web site that are
supposed to allow users to modify their own AD account attributes,
limited of course to things like their email address, URL, etc. I was
hoping to connect to LDAP using secure authentication as described on
a few tech web pages, and the connection works fine but when it's time
to commit the changes with .SetInfo, the script fails with:
Active Directory error '80070005'
...
|
by: jeremy |
last post by:
Hello.
I have an asp.net application that resides on a non-DC / BDC Sharepoint
Server (although it is logged into the domain). The application will perform
lookups based on the current user (integrated auth) to an LDAP server which
requires no login (AuthenticationTypes.None). When I run it, I get the
following ambiguous error:
Security Exception
Description: The application attempted to perform an operation not allowed
|
by: Jean-Marie Vaneskahian |
last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net?
I am in need of a .Net class that will allow for the parsing of a LDAP
LDIF file. An LDIF file is the standard format for representing LDAP
objects. I need to be able to read the records from an LDIF file into
..Net.
There exists a Perl module that will do exactly this called
Net::LDAP::LDIF but I am wanting to port my code over to .Net and
cannot find anything with similar...
|
by: rcmn |
last post by:
i'm running around in circle trying to to use python/ldap/ on
win32(WinXP). I want to write a script that read SQL data(no pbm) and
insert member in a AD group(pbm).I used the module
Active_Directory(very easy to use).but it read only AD.
So i have been try to install python-ldap on a win32/python2.4
install.But each time i try
------------------------
setup.py build
------------------------
| |
by: Cruelemort |
last post by:
All,
I am hoping someone would be able to help me with a problem. I have an
LDAP server running on a linux box, this LDAP server contains a
telephone list in various groupings, the ldif file of which is -
dn: dc=example,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
|
by: MrHelpMe |
last post by:
Sorry everyone,
NOTE: I have posted this question to another site but unfortunately,
am not getting the answers I need only because those helping haven't
worked with ASP.
I am in desperate need of a fix. I am using classic asp and making a
connection to LDAP server using SQL code under IIS 5 on my localhost
and it works great. I have a form and form fields that pull from
active directory. Now, once I get the web team to deploy these...
|
by: thegainer |
last post by:
hi all,
I am new to this forum. I did some small projects in php using mysql connectivity. I used wamp for this. latform is windows XP and wamp is installed. I have no idea about LDAP. I know only the basic things. I have do an assignment to search(retrieve) the info stored in LDAP using php connectivity.
Can any one help me with following things :
1. Will I require any LDAP server to be installed on my pc?
2. Should I make any changes...
|
by: Sells, Fred |
last post by:
I'm running python 2.5 (or 2.4) in an XP environment.
I downloaded and installed the .dll's from OpenLDAP-2.4.8+OpenSSL-0.9.8g-Win32.zip and copied the .dll's in c:/windows/system32 as instructed
now I get this error. Is there anyway to avoid building the python_ldap binaries? Apart from being lazy, I've got a secure system policy issue if I start compiling apps. I could give up and just start running in linux, but myxp environment is...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |