X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=source3%2Flibads%2Fkrb5_setpw.c;h=8079c0953fc65391ce936228bb6e715d23b21dd8;hb=f2d1f19a66ebaf9b88d23c0faa2412536cc74cda;hp=a49b6cbe3b0ee8a01ed6ec30286544d0e175921c;hpb=2fb5c7c580a3fff3c7d477b65a1c4852af86433b;p=vlendec%2Fsamba-autobuild%2F.git diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c index a49b6cbe3b0..8079c0953fc 100644 --- a/source3/libads/krb5_setpw.c +++ b/source3/libads/krb5_setpw.c @@ -471,4 +471,35 @@ ADS_STATUS kerberos_set_password(const char *kpasswd_server, } +/** + * Set the machine account password + * @param ads connection to ads server + * @param hostname machine whose password is being set + * @param password new password + * @return status of password change + **/ +ADS_STATUS ads_set_machine_password(ADS_STRUCT *ads, + const char *hostname, + const char *password) +{ + ADS_STATUS status; + char *host = strdup(hostname); + char *principal; + + strlower(host); + + /* + we need to use the '$' form of the name here, as otherwise the + server might end up setting the password for a user instead + */ + asprintf(&principal, "%s$@%s", host, ads->auth.realm); + + status = krb5_set_password(ads->auth.kdc_server, principal, password, ads->auth.time_offset); + + free(host); + free(principal); + + return status; +} + #endif