---
title: "changePassword(_:toPassword:)"
framework: opendirectory
role: symbol
role_heading: Instance Method
path: "opendirectory/odrecord/changepassword(_:topassword:)"
---

# changePassword(_:toPassword:)

Changes the record’s password.

## Declaration

```swift
func changePassword(_ oldPassword: String!, toPassword newPassword: String!) throws
```

## Parameters

- `oldPassword`: The record’s old password. Can be nil if the user has the proper permissions.
- `newPassword`: The new password.

## Discussion

Discussion note: In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Managing Authentication

- [setNodeCredentials(_:password:)](opendirectory/odrecord/setnodecredentials(_:password:).md)
- [setNodeCredentialsWithRecordType(_:authenticationType:authenticationItems:continueItems:context:)](opendirectory/odrecord/setnodecredentialswithrecordtype(_:authenticationtype:authenticationitems:continueitems:context:).md)
- [verifyExtended(withAuthenticationType:authenticationItems:continueItems:context:)](opendirectory/odrecord/verifyextended(withauthenticationtype:authenticationitems:continueitems:context:).md)
- [verifyPassword(_:)](opendirectory/odrecord/verifypassword(_:).md)
