Results 1 to 11 of 11

Thread: Security setup for directories using xml api - Password Protect Directories

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Default Security setup for directories using xml api - Password Protect Directories

    Hi

    Is there anyone knows how to enable the password protection for a directory and create a user/password for it using XML api?



    Regards,
    Nam

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by nhk15 View Post
    Hi

    Is there anyone knows how to enable the password protection for a directory and create a user/password for it using XML api?



    Regards,
    Nam
    Here's the raw API1 call for setting the password protection for a directory:

    Code:
    <cpanel Htaccess="set_pass(directory, username, password)">
    You can then call this API1 function from the XML API. If you are not familiar with how to do that, feel welcome to use the PHP class Matt has written for using our XML API:

    http://forums.cpanel.net/showthread.php?t=111897

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Default

    Thank you for your reply. It works great.

    Just one more thing, what is the xml api function to turn on/off for Password protect directories?

    When i tried it through cPanel, the url looks like this below:

    after turning on the option:
    http_s://mydomain.com:2083/frontend/x3/htaccess/changepro.html?protected=1&resname=mysite&action2=Save&dir=%2Fhome%2Ffusername%2Fpublic_html%2F

    after turning off the option:
    http_s://mydomain.com:2083/frontend/x3/htaccess/changepro.html?resname=&action2=Save&dir=%2Fhome%2Fusername%2Fpublic_html%2F

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by nhk15 View Post
    Thank you for your reply. It works great.

    Just one more thing, what is the xml api function to turn on/off for Password protect directories?

    When i tried it through cPanel, the url looks like this below:

    after turning on the option:
    http_s://mydomain.com:2083/frontend/x3/htaccess/changepro.html?protected=1&resname=mysite&action2=Save&dir=%2Fhome%2Ffusername%2Fpublic_html%2F

    after turning off the option:
    http_s://mydomain.com:2083/frontend/x3/htaccess/changepro.html?resname=&action2=Save&dir=%2Fhome%2Fusername%2Fpublic_html%2F
    The API call I provided earlier is for creating a user for a password protected directory. To enable or disable password protection, this is the raw API1 call:

    Code:
    <cpanel Htaccess="set_protect(directory,protected,resource_name)">
    Where directory is the directory to enable/disable protection for.

    Protected is 1 if directory protection is to be enabled, 0 to disable

    resource_name is text you can choose to display within the password prompt that is displayed by the browser to let users know what they're logging into (e.g. Member Area).

    The XML API URL for this would be:

    Code:
    /xml-api/cpanel?user=username&xmlin=<cpanelaction><module>Htaccess</module><func>set_protect</func><apiversion>1</apiversion><args>/home/username/public_html/something</args><args>1</args><args>Member Area</args></cpanelaction>
    You can view our documentation for calling API1 functions from the XML API at:

    http://twiki.cpanel.net/twiki/bin/vi...With_arguments

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Thumbs up

    oh Cool, thank you so much!

  6. #6
    Member
    Join Date
    Oct 2002
    Posts
    104

    Default

    I have another post where I'm trying to compare the username and password (Reference: cPanel Forums - Search Results) Does anyone know how to compare username and passwords generated by the cPanel XML API?

  7. #7
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by netarus View Post
    I have another post where I'm trying to compare the username and password (Reference: cPanel Forums - Search Results) Does anyone know how to compare username and passwords generated by the cPanel XML API?
    Just a head's up, search results expire after a period of time so linking to search results isn't a good idea. I recommend linking directly to the threads you were trying to direct attention to.

  8. #8
    Member
    Join Date
    Oct 2002
    Posts
    104

    Default

    Good call. Sorry about that... here is the related post... I cannot seem to figure out how to compare .htaccess username and passwords with the cPanel API.

    http://forums.cpanel.net/f42/passwor...ds-157297.html

  9. #9
    Member
    Join Date
    Oct 2002
    Posts
    104

    Default

    Is there anyone else that can assist with this? Thank you for any replies.

  10. #10
    BANNED
    Join Date
    Jun 2005
    Posts
    2,023

    Default

    I am not 100% certain what it is that you are actually asking and it has been almost a month since your previous post.

    Still playing around with .htpasswd access setup?

  11. #11
    Member
    Join Date
    Oct 2002
    Posts
    104

    Default

    Thank you for your reply. Let me try phrasing it another way...

    You can set a password on a directory using cPanel (stored in htpasswd file), how do you programmatically using PHP authenticate a user to access that password protected directory? We do not want the web browser prompts to appear. They should authenticate directly through our PHP code.

    This is the related post - http://forums.cpanel.net/f42/passwor...ds-157297.html

    Thank you again for your reply and any updates or questions you may have for clarification.

Similar Threads

  1. How to password protect several directories
    By lucaskirsch in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 10-10-2008, 10:15 AM
  2. Password Protect Directories
    By Jump Network in forum Security
    Replies: 2
    Last Post: 07-07-2008, 10:09 AM
  3. Password Protect Directories
    By wwwnz in forum New User Questions
    Replies: 14
    Last Post: 07-04-2008, 09:35 AM
  4. Password protect directories
    By bpmod in forum cPanel & WHM Discussions
    Replies: 7
    Last Post: 10-04-2006, 11:46 PM
  5. Password protect directories
    By futuron in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 01-10-2005, 11:11 PM