IssueCookiesToNewUser Method

This method is used to issue the necessary cookies to a new registered user account that did not previously have a corresponding anonymous cookie account.

IDL Definition

HRESULT IssueCookiesToNewUser(
BSTR bszUserName, 
[out, retval] BSTR* pbstrNewGUIDValue
);

Parameters

bszUserName

The name of the new user.

pbstrNewGUIDValue

On return, the BSTR variable contains the user's new GUID value.

Return Values

A standard HRESULT value

Remarks

This method is used to set a new user's Membership cookies during the construction of a new user account as well as generate a GUID value for the account.  If the user already has a GUID value associated, use the IssueOldCookiesToNewUser method.

One must explicitly update the new account's directory properties with the new GUID value as this is a required property.

Example

<%
  NewUserName = "FredJ"
  ID = "o=company/ou=members/cn=administrator"
  Password = "password"

  Set IUserObjects = Server.CreateObject("Membership.UserObjects.1")
  '  assume this AUO is going to be used to create a new user
  ' with username "FredJ"

  ' set the new username in the AUO
  IUserObjects.SetUserName(cstr(NewUserName))

  ' use these binding credentials to access the DS
  IUserObjects.BinsAs "", ID,Password

  '  Now work with cookies  
  Set IVerifUsr = Server.CreateObject("Membership.VerifUsr.1")
  '  Check to see if the user already has a GUID
  If Request("MEMUSER") <> "" Then
    ' No username and likely no GUID;  Issue Cookies and Get a new GUID
    GUIDValue = IVerifUsr.IssueCookiesToNewUser(Username)

    '  ADSI object loaded and the value put 
    '  the required GUID value in the object
    IUserObjects.Put "GUID", cstr(GUIDValue)

   Else
    GUIDValue = IUserObjects.Get("GUID")
    IVerifUsr.IssueOldCookiesToNewUser Username, GUIDValue
   End If

    ' the info in the ADSI object committed to DS
    IUserObjects.SetInfo
%>

© 1997-1998 Microsoft Corporation. All rights reserved.