1

As i am new to python and ldap, please hep me convert the below shell code into python(version 2.6.6).

can some pls explain what this below shell code does and what is the use of -b option here

Shell code :

ldapsearch -x -h ldap.bbc.network.lcl -p 3477 -b "DC=bbc,DC=network,DC=lcl" -D "CN=LDAP\, Mine,OU=Resource Accounts,OU=Enterprise,DC=bbc,DC=network,DC=lcl" -w f2oH@LQ^911 "center=1234"
5
  • If you just want to run that command, do it with Bash. Using Python for that won't give any benefit. Or do you want to write a Python version of that command? BTW, Python 2.6.6 is rather ancient. You should seriously consider learning Python 3, Python 2 will reach its official End Of Life in 2020. Commented May 27, 2018 at 11:44
  • Actually , i need to do this functionality in python .Thatswhy. But i am new to both shell and python Commented May 27, 2018 at 11:47
  • 2
    Of course you could write a Python script that just runs a shell command, but one of Pythons' strengths is the vast selection of libraries. Have a look at python-ldap.org Commented May 27, 2018 at 12:30
  • The shell code will never have an End Of Life and learning one thing is easier than two. I'd focus on polishing what already works rather than rewriting it to get back to where you already are. Plus shell programmers don't worry about PEP compliance which makes it easier to avoid a few neuroses. Commented May 27, 2018 at 13:29
  • Pls, someone say "what is the username from the shell code " Commented Jun 7, 2018 at 10:08

1 Answer 1

1

To find out what each option does, take a look at the man page of command, here.

As stated there:

-b searchbase Use searchbase as the starting point for the search instead of the default.

To run the command via python interpreter you can use structures like this:

For more info visit this Q/A.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.