Partager via


4.1 Creating a User Account

The following sequence of methods and parameters creates a user account given a network address of "msdc-1", a domain name of "ms", and a user name of "testuser".

  1. Send SamrConnect.

    Parameter field

    Parameter value

    ServerName

    msdc-1

    DesiredAccess

    0x31

  2. Receive SamrConnect.

    Parameter field

    Parameter value

    Status

    0

    ServerHandle

    [implementation-specific value] serverHandle

  3. Send SamrLookupDomainInSamServer.

    Parameter field

    Parameter value

    ServerHandle

    serverHandle

    Name.Length

    4

    Name.MaximumLength

    4

    Name.Buffer

    ms

  4. Receive SamrLookupDomainInSamServer.

    Parameter field

    Parameter value

    Status

    0

    DomainId

    [implementation-specific SID]. For example: S-1-5-21-3448151421-356457007-600757626

  5. Send SamrOpenDomain.

    Parameter field

    Parameter value

    ServerHandle

    serverHandle

    DesiredAccess

    0x00000010

    DomainId

    S-1-5-21-3448151421-356457007-600757626

  6. Receive SamrOpenDomain.

    Parameter field

    Parameter value

    Status

    0

    DomainHandle

    [implementation-specific value] domainHandle

  7. Send SamrCreateUser2InDomain.

    Parameter field

    Parameter value

    DomainHandle

    domainHandle

    Name.Length

    16

    Name.MaximumLength

    16

    Name.Buffer

    testuser

    AccountType

    0x00000080

    DesiredAccess

    0x02000000

  8. Receive SamrCreateUser2InDomain.

    Parameter field

    Parameter value

    Status

    0

    UserHandle

    [implementation-specific value] userHandle

    GrantedAccess

    0xf07ff

    RelativeId

    2810

  9. Send SamrCloseHandle.

    Parameter field

    Parameter value

    Handle

    userHandle

  10. Receive SamrCloseHandle.

    Parameter field

    Parameter value

    Status

    0

    Handle

    0

  11. Send SamrCloseHandle.

    Parameter field

    Parameter value

    Handle

    domainHandle

  12. Receive SamrCloseHandle.

    Parameter field

    Parameter value

    Status

    0

    Handle

    0

  13. Send SamrCloseHandle.

    Parameter field

    Parameter value

    Handle

    serverHandle

  14. Receive SamrCloseHandle.

    Parameter field

    Parameter value

    Status

    0

    Handle

    0