WebSetUserAuthDigest Function

Action

Sets the password for digest user authentication.

注: This function overrides the corresponding setting on the Authentication tab of the Profile SettingsWeb dialog. In contrast to the WebSetUserAuth function, this function does not change the credentials for Basic or NTLM/Kerberos authentication.

Include file

WebAPI.bdh

Syntax

WebSetUserAuthDigest( in sUsername : string allownull,
                      in sPassword : string allownull,
                      in sUrl      : string allownull,
                      in sRealm    : string allownull ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sUsername User name; this parameter may be NULL.
sPassword Password (optional)
sUrl URL representing protection space for digest authentication (optional)
sRealm Realm for which to set authentication (optional). This realm provides a special context for the username/password to a Web site. For example, www.MyCompany.com uses realm "www.MyCompany.com", whereas www.MyCompany.com/support uses realm "MyCompany support".

Calling this function inserts the username/password pair into the authentication database used when a server requests digest authentication (code 401). On subsequent requests, the authentication header line is added to the request headers automatically.

  • To set the default username/password, call WebSetUserAuthDigest("user1", "pass1");

  • To delete the default username/password, call WebSetUserAuthDigest("", ""); This does not remove the entry from the authentication database.

  • To remove all cached authentication entries from the cookie database, call WebSetUserAuthDigest(NULL);

  • In addition, you can add authentication entries directly to the authentication database by providing a protection space and the realm. For example, WebSetUserAuthDigest("DigestcAuthUser", "DigestAuthPass", "http://lab1/testsite/", "lab1");

Example

dcltrans
  transaction TWeb
  begin
    WebSetUserAuthDigest("domain\\user", "password");
    WebPageUrl("http://www.mydomain.com/");
  end TWeb;