<%@ Language=VBScript%>
<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<%
' This example demonstrates how to add a user.
' Objects demonstrated by this example:
' InfoObjects Collection
' InfoObjects.Add method
' IStore.Commit method
' User object (All properties except for Aliases and groups).
'================================================
Function AddNewUser(IStore, Name, Description, FullName, Password, PasswordExpires, ChangePasswordAtNextLogon, AllowChangePassword, Connection)
' This function adds a new user to the system.
' Parameters:
' IStore (InfoStore) - The InfoStore object.
' Name (string) - The name of the new user.
' Description (string) - The description of the new user.
' FullName (string) - The full name of the new user.
' Password (string) - The password for the new user.
' PasswordExpires (boolean) - Sets whether the users password expires.
' ChangePasswordAtNextLogon (boolean) - Sets whether the user has to change password at next logon.
' AllowChangePassword (boolean) - Sets whether the user is able to change their password.
' AllowChangePassword (CEConnectionType) - Sets whether the user is a current or named user.
' Returns: Nothing.
On Error Resume Next
' Get the User Plugin library and add a new User object.
Set PluginMgr = IStore.PluginManager
Set UserPlugin = PluginMgr.PluginInfo("CrystalEnterprise.User")
Set NewUsers = IStore.NewInfoObjectCollection()
NewUsers.Add (UserPlugin)
' Get the new User object for base properties and
' get the interface object for specific user properties.
Set NewUser = NewUsers.Item(1)
Set NewUserInterface = NewUser.PluginInterface("")
'Set user name, description.
NewUser.Title = Name
NewUser.Description = Description
'Set user specific properties.
NewUserInterface.FullName = FullName
NewUserInterface.PasswordExpires = PasswordExpires
NewUserInterface.AllowChangePassword = AllowChangePassword
NewUserInterface.ChangePasswordAtNextLogon = ChangePasswordAtNextLogon
NewUserInterface.Connection = Connection
NewUserInterface.NewPassword = Password
'Save the user to the system.
IStore.Commit NewUsers
If (Err.Number = 0) Then
Response.Write "<BR>User '" & NewUser.Title & "' successfully created."
Else
Response.Write "<BR>Error creating User - Permission not granted, or invalid Data."
End If
End Function
Function Main()
' If the infostore object is not found then display an error message.
If ((Not IsObject(Session("IStore"))) or (isNull(Session("IStore")))) Then
Response.Write "Example failed: try logging on first!"
Exit Function
Else
'Retrieve the InfoStore object.
Set IStore = Session("IStore")
End If
Response.Write "<H2>Example - Adding and removing users</H2>"
AddNewUser IStore, "Joe Schmoe", "A very special person.", "Joe Schmoe", "Password", true, true, true, 1
Response.Write "</FORM>"
End Function
Main ()
%>