ldapsearch and XML


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users ldapsearch and XML
# 1  
Old 01-29-2010
ldapsearch and XML

Hello all

I would like to know if it's possible to extract users from Active Directory and parse the output to obtain a XML file with specific format.

So the AD is a windows machine, and I would like to extract from a red hat linux serveur. I try ldapsearch command and ok I'm abble to extract data, but I must change the file to XML special file.
Just one exemple of parsing could be ok...
Thanks a lot
# 2  
Old 01-30-2010
Rather than looking at an XML export from AD, how about running:
Code:
$ getent passwd
$ getent group

for instance to get lists of each, is that what you are after?

This assumes nsswitch.conf, pam.conf and ldap.conf are configured to use LDAP to query AD on your RedHat machine. Or by using SAMBA/Winbind as is mentioned in Active Directory Integration with Samba in RHEL/CentOS 4 ?? Linux Mail Server Setup and Howto Guide and in http://www.cendio.com/resources/docs/tag/winauth.html .
# 3  
Old 02-01-2010
This can be done in perl using Net::LDAP module and XML::Writer module.
# 4  
Old 02-03-2010
Hello Tony
I do not anderstand your answer...The command you specify.
Well I'll look the perl ldap module,
Maybe some of you have some exemple of code?

Thanks
# 5  
Old 02-03-2010
If you run the getent commands I have suggested on the Unix client you will get a list of all the users and groups without having to export and munge files on the LDAP server.
# 6  
Old 02-05-2010
Quote:
Originally Posted by TonyFullerMalv
If you run the getent commands I have suggested on the Unix client you will get a list of all the users and groups without having to export and munge files on the LDAP server.
It's possible the OP would like to extract Active Directory data that has nothing to do with his/her Linux authentication scheme, perhaps for some other use.


It's possible to pull the data with Perl's Net::LDAP and also with Python. And you don't even need a module to write XML data, though it might be easier if you wanted to write very complex XML.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parser ldapsearch to mysql

Hi, I'm trying to make a bash script to read LDAP (from MS active directory with ldapsearch), extract the fields 'mail', 'division', 'memberOf', 'userAccountControl', 'uidNumber', 'name', 'sAMAccountName' and save in a mysql database. I have extracted the fields with ldapsearch but I am... (2 Replies)
Discussion started by: somachibun
2 Replies

2. UNIX for Beginners Questions & Answers

Ldapsearch using variable will not work

When I execute the code below with cn set to the $adgroup variable, I get the following error: Invalid DN syntax (34) Additional information: 0000208F: NameErr: DSID-031001F7, problem 2006 (BAD_NAME), data 8349, best match of: ,ou=Resource,ou=groups,dc=abc,dc=somecompany,dc=com' If I set cn... (6 Replies)
Discussion started by: who10
6 Replies

3. UNIX for Beginners Questions & Answers

Help with output from ldapsearch command

Using ldapsearch, I've built the following command to get what I need. ldapsearch -x -LLL -E pr=200/noprompt -h abc-loc.somecompany.com -D "account@somecompany.com" -w password -b "ou=End Users,ou=Accounts,dc=abc,dc=somecompany,dc=com" -s sub '(distinguishedName=CN=Bob\\, Billy J,OU=End... (8 Replies)
Discussion started by: who10
8 Replies

4. Red Hat

Ldapsearch problem

Hi I'm not familiar with ldap and I hope someone to help me. I need to get some attribute value from ldap DB. When i run the following command is OK: ldapsearch -h localhost -p 16611 -x -D cn=user -w passwd -b msisdn=359502479649,dc=MSISDN,DC=C-NTDB "(objectClass=SUBINNSS)" refinmocNAME the... (0 Replies)
Discussion started by: vasil
0 Replies

5. UNIX for Dummies Questions & Answers

Need assistance on using ldapsearch

Never knew of this command ldapsearch, but I would like to use it to lookup a single user and return where their office is. Is this possible? I'm totally starting from scratch. I already saw some of the gurus say read the man page, which is pretty greek when you don't know the details of... (1 Reply)
Discussion started by: srhadden
1 Replies

6. Red Hat

ldapsearch bash script help

Hi there everyone. I'm trying to make a bash script that accepts some arguments ans give's back some info about LDAP users and servers. I have this function : has_group_access(){ result=$(ldapsearch -LLL "cn=${GROUP_NAME}" cn member | cut -d"," -f1 | cut -d":" -f2 | cut -d"=" -f2 | grep... (1 Reply)
Discussion started by: theboogymaster
1 Replies

7. AIX

ldapsearch to find DN for a user

How can I do a ldapsearch to find a DN for a user when I know the exact cn for that user out of active directory. I have tried several different commands (hundreds) but need the -b with the full dn to perform the search using ldapsearch from AIX. I am trying to find the OU for a user and the... (3 Replies)
Discussion started by: cchart3
3 Replies

8. Programming

LDAPSEARCH in C

Hi all, I've been searching for ldapsearch function these few days. Still I couldn't found the solution. I would like to translate this query ldapsearch -x -LLL -h new_IP -p new_Port -D "cn=jw" -w "dummy" -b "id=2311,o=WC,c=jp" -s sub to ldap_search_ext_s() function in C program. ... (0 Replies)
Discussion started by: tailangong
0 Replies

9. UNIX for Dummies Questions & Answers

ldapsearch time limit

We have an application that uses Active directory to authenticate the users. the admins of the app. were complaining because the windows domain controller they are going against is not very stable. I wrote a shell script using ldapsearch to look up a user against the domain controller their app... (2 Replies)
Discussion started by: jayjabour
2 Replies

10. Red Hat

ldapsearch doesnt work.

Hii All, I am using openldap v2.3 on redhat El-4. When i run ldapsearch it returns all the entries. The command runs successfully. But when I run the ldapsearch with following filter option it doesnt work and immediately returns to the shell. ldapsearch uidNumber>=2000 I've started slapd... (0 Replies)
Discussion started by: shamik
0 Replies
Login or Register to Ask a Question