代码之家  ›  专栏  ›  技术社区  ›  Kristopher Johnson

通过编程或脚本更改Mac OS X用户密码

  •  1
  • Kristopher Johnson  · 技术社区  · 16 年前

    2 回复  |  直到 16 年前
        1
  •  2
  •   toma    7 年前

    苹果公司介绍 CSIdentitySetPassword Mac OS 10.5中允许按如下方式更改密码的API:

    #import <Collaboration/Collaboration.h>
    
        AuthorizationRef authRef = NULL; // You have to initialize authRef
    
        CBIdentityAuthority *authority = [CBIdentityAuthority defaultIdentityAuthority];
        CSIdentityRef identity = [CBIdentity identityWithName:user authority:authority].CSIdentity;
        if (CSIdentityGetClass(identity) == kCSIdentityClassUser) {
            CSIdentitySetPassword(identity, (__bridge CFStringRef)newPassword);
            CSIdentityCommit(identity, authRef, NULL);
        }
    

    this 回答

        2
  •  1
  •   Mehrdad Afshari    16 年前

    使用 passwd shell命令。