Jump to content

chrishumphr1es

Member
  • Posts

    12
  • Joined

  • Last visited

chrishumphr1es's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. Thank you! Sorry I am just getting back. Do I move the py file to usr/local/bin/python?
  2. Thanks so much Deanishe, I really appreciate your time on this.
  3. I think I've confused everyone pretty well for all of this, haha. Thank you guys for what you've done. I'm just going to post my workflow so I'll can show you what I've got. My workflow: https://www.dropbox.com/s/ujyop86u2ohercu/LDAPSearch.alfredworkflow - I've removed my login info and just have generic data in place. My hope is that i could 1. Search my company's ldap database 2. output the data I need into a file alfred can read 3. Be able to list the data similar to how alfred does with spotlighted contacts 4. be able to create a new email message from the listing. Any feedback you guys have would be great.
  4. Ok, thanks so much. Does this go in my script filter? I know my responses are probably frustrating but I am new at this and just trying to figure it out. Please feel free to just not respond if you'd rather not, but you've been helpful so far and I really appreciate it. Would my script filter be as follows: sys.stdout.write('/tmp/ldapres.xml'.encode('utf-8')) ?
  5. So how do I get alfred to show that? I think if you could help me with that part, I'd be all set.
  6. Ok great, I think I've fixed it. My xmlfile looks like this: <?xml version="1.0"?> <items> <items><item arg="email" uid="username" valid="YES"><title title="name" /><subtitle subtitle="telephoneNumber :+1 111 111 1111 mail : mail" /></item></items> </items> Will this work for the script filter? How do I tell the script filter to call the file? I've been reading all of the docs in the forums, and am still a bit stuck.
  7. Thank you for your comments, they have been very helpful. I actually found a ldap python library online and a few helpful scripts which helped me write a python script that returns the info I need, my only confusion now is reformatting the xml file into the correct alfred format. Here's my script: #!/usr/local/bin/python import ldap, sys if __name__ == "__main__": ldap_server="ldap_server" username = "username" password= "password" # the following is the user_dn format provided by the ldap server user_dn = "uid="+username+",ou=people,dc=ex,dc=com" # adjust this to your base dn for searching base_dn = "dc=ex,dc=com" connect = ldap.open(ldap_server) search_filter = "uid="+username try: #if authentication successful, get the full user data connect.bind_s(user_dn,password) retrieveAttributes = ["mail", "telephoneNumber", "cn"] result = connect.search_s(base_dn,ldap.SCOPE_SUBTREE,search_filter,retrieveAttributes) # return all user data results connect.unbind_s() sys.stdout = open('/tmp/ldapres.xml', 'r+') print result except ldap.LDAPError: connect.unbind_s() print "authentication error" and here is my xml file: [('uid=username, ou=people, dc=ex, dc=com', {'telephoneNumber': ['+1 111 111 1111'], 'mail': ['email'], 'cn': ['full name']})] Any ideas on how to get this into the format alfred needs to display it correctly would be super helpful. I've replaced my specific login info and output with generics Thanks!
  8. I have, I'm just not sure how to go about connecting the dots..I'm pretty green at all of this. Here's my output from the terminal (using generic parameters instead of specific for privacy) : command: ldapsearch -h ldap.server.com -x -b "dc=company,dc=com" "uid=*username*" "telephoneNumber" "mail" "uid" # extended LDIF # # LDAPv3 # base with scope subtree # filter: uid=*username* # requesting: telephoneNumber mail uid # # username, people, ex.com dn: uid=username, ou=people, dc=company, dc=com telephoneNumber: +1 111 111-1111 mail: email uid: username # search result search: 2 result: 0 Success # numResponses: 2 # numEntries: 1 I'd like to be able to return the telephonNumber, mail, and uid values back to alfred similar to the way it does for the built-in contacts. Is this possible? Even better would be to be able to trigger an email from the mail value.
  9. My goal for my workflow is to run a bash command that uses ldapsearch to search my university's directory and return a list of contacts that operates similar to Alfred's contact search. I've got my bash script running fine, but I'm just unclear on how to format the returned information in the best way. Any guidance on script filtering and bash script returning would be great! I am relatively new at this, so excuse my poor terminology.
  10. Thanks so much! So here's where I am at: I've gotten ldapsearch to work, but I can only get it to return based on uid. Whenever I do this in the alfred workflow, I always get "contact list result" returned. any idea why?
  11. Hi Olivier, Very excited for this workflow. My only confusion is what parameters I need to change on the python script. I am familiar with python to a certain degree, but still need guidance navigating it every now and then. Could you provide the parts of the script that I need to replace with my own company's ldap info? Thanks!
×
×
  • Create New...