php写AD域拉取账号,怎么实现用php来修改AD域用户名的密码

$host = "ldap://10.100.1.10:389"; $domain = "dec.com"; $user =$_POST["username"]; $oldpswd=$_POST["oldpswd"]; $pwdtxt=$_POST["newpswrd"]; $conn = ldap_connect($host) or die("Could not connect!" ); ldap_set_option ( $conn, LDAP_OPT_PROTOCOL

$host = "ldap://10.100.1.10:389";

$domain = "dec.com";

$user =$_POST["username"];

$oldpswd=$_POST["oldpswd"];

$pwdtxt=$_POST["newpswrd"];

$conn = ldap_connect($host) or die("Could not connect!" );

ldap_set_option ( $conn, LDAP_OPT_PROTOCOL_VERSION, 3 );

ldap_set_option ( $conn, LDAP_OPT_REFERRALS, 0 );

$bd = ldap_bind($conn,$user."@".$domain,$oldpswd);

if($bd){

if(ldap_mod_replace($bd,$pwdtxt))           {

echo"succeded";

} else {

echo "failed";

}

为什么老是失败呢???

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用以下代码通过 REST API 在 Python3 中从 Azure DevOps 拉取代码: ```python import base64 import requests # Azure DevOps organization URL organization_url = '<your organization URL>' # Personal access token (PAT) with Code -> Read & Write scope personal_access_token = '<your PAT>' # Project name project_name = '<your project name>' # Repository name repo_name = '<your repository name>' # Branch name branch_name = '<your branch name>' # create credentials string credentials = "{}:{}".format("", personal_access_token) credentials_bytes = credentials.encode('ascii') base64_credentials_bytes = base64.b64encode(credentials_bytes) base64_credentials = base64_credentials_bytes.decode('ascii') # define headers headers = { 'Authorization': 'Basic {}'.format(base64_credentials) } # define URL url = '{}/{}/{}/_apis/git/repositories/{}/items?path=%2F&version=GB{}&recursionLevel=Full&includeContentMetadata=true&latestProcessedChange=true'.format(organization_url, project_name, repo_name, branch_name) # send GET request response = requests.get(url=url, headers=headers) # print response content print(response.content) ``` 在代码中,您需要使用 Azure DevOps 组织的 URL、个人访问令牌(PAT)以及您要拉取代码的项目、存储库和分支名称。然后,您需要对这些凭据进行身份验证,并将它们用作 REST API 请求的标头。 最后,您可以使用 Python 的 `requests` 库向 Azure DevOps 发送 GET 请求,并打印响应内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值