Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning users to groups using sql behind the scenes 1

Status
Not open for further replies.

jaburke

Programmer
May 20, 2002
156
US
I want to be able to create users and assign them to their groups using sql. Is that possible? I have looked at the CI_INFOOBJECTS and i don't see any group information there. Am I missing it?

Any help and/or adivce would be appreciated.

Thanks!!
 
Hi,
Go to
and do a search for a file named:
ce10_obj_asp_samples.exe

It contains code examples showing how to manipulate groups/users/etc. without using the CMC...

It is for CE10 but may be adaptable to earlier versions
[profile]
 
And you probably will not be able to do it "using sql" if you mean something like INSERT INTO CI_INFOOBJECTS (NAME) VALUES ('Voldemort');

The tables are object tables and you will need .csp, .asp, or java to manipulate the object properties. The sample code suggested by Turkbear will give you some ideas. CE9 also icludes the Crystal Web Wizard on your server*. This will generate a simple Admin application which you can customize from the samples. I've built an Add User page to add in, if you get that far and would like to see it.

*All our CE components are on one server, so I can't tell you if the CWW is associated with one component in particular.
 
Hi mdwyer,
I would like to see your Add User page for sure.

Thanks,
Jennifer
 
Hi jaburke,
Here is a sub I have created. It's from my custom pages. This sub in a csp page where the user logs in the CE9. If the user does not exist in CE9, the sub create the user in CE9 and adds him/her to a group and logs the user in CE..
enjoy..

Sub LogonUser( username, password, apsname, authentication, logon_error )
ON ERROR RESUME NEXT

Dim sm
Dim es
Dim ltm
Dim tempRS

'INSTANTIATE INFOSTORE OBJECT FOR SESSION
Set sm = CreateObject("CrystalEnterprise.SessionMgr")
If ( Err.Number <> 0) Then
logon_error = " Problem in creating the Crystal Session Object "
LoginSuccess = FALSE
Exit Sub
End If

Set es = sm.Logon(username, password, apsname, authentication)

'USER NOT FOUND CODE THIS ERROR IS THROWN SO CREATE THE USER IN CE
If (Err.Number =-2147211005 ) Then
Err.Number = 0
'LOGON TO THE SYSTEM AS ADMINISTRATOR
'CREATE THE USER
'ASSIGN TO A GROUP
'LOG OFF THE SYSTEM
Dim IStore
Dim pluginMgr
Dim UserPlugin
Dim NewInfoObjects
Dim InfoObject
Dim NewUser
Dim MemberGroups
' CREATE AN ENTERPRISE MANAGER OBJECT FROM THE SESSIONMANAGER OBJECT with the Administrator user
Set es = sm.Logon ("administrator","admin_password","APS_Name","secEnterprise")
If Err.number <> 0 Then
' the error occurs because Administrator couldn't logon
logon_error = " The new user error:ADMIN RIGHTS. Please contact to Burc Kaya."
LoginSuccess = FALSE
Exit Sub
End If
' CREATE INFOSTORE OBJECT FROM ENTERPRISE SESSION OBJECT
Set IStore = es.Service ("", "InfoStore")
' CREATE A PLUGINMANAGER (THAT MANAGES CRYSTAL OBJECTS)
Set pluginMgr = IStore.PluginManager
' CREATE A USERPLUGIN (THAT MANAGES USER OBJECT)
Set UserPlugin = pluginMgr.PluginInfo("CrystalEnterprise.User")
' CREATE AN INFOSTOREOBJECT (ANY CRYSTAL OBJECT CONTAINER)
Set NewInfoObjects = IStore.NewInfoObjectCollection()
' ADD THE USERPLUGIN TO THE INFOOBJECT
NewInfoObjects.Add(UserPlugin)
' INITIALIZE THE USER OBJECT
Set InfoObject = NewInfoObjects.Item(1)
' CREATE A NEW USER INSTANCE FROM THE USER OBJECT
Set NewUser = InfoObject.PluginInterface("")
' CREATE A MEMBERGROUP INSTANCE FROM THE USER OBJECT
Set MemberGroups = InfoObject.PluginInterface("").Groups
' SET THE USER OBJECT INTO A GROUP BASED ON THE USERTYPE
Select Case usertype
' CHANGE THE NUMBERS TO REFLECT THE GROUPS IN CRYSTAL ENTERPRISE
Case 0,1
MemberGroups.Add(Int(120345))
Case 2
MemberGroups.Add(Int(120376))
Case 3
MemberGroups.Add(Int(120380))
Case 4
MemberGroups.Add(Int(120384))
Case 5
MemberGroups.Add(Int(120388))
Case 6
MemberGroups.Add(Int(120392))
Case 7,8,9
MemberGroups.Add(Int(120396))
End Select

InfoObject.Title = userid
'InfoObject.Description = raises an error here so don't use this line
NewUser.FullName = name
NewUser.PasswordExpires = False
NewUser.AllowChangePassword = False
NewUser.NewPassword = "userpassword"
IStore.Commit (NewInfoObjects)

'Release the Administrator's Enterprise Session
Set es = Nothing

If Err.number <> 0 Then
logon_error = err.description
LoginSuccess = FALSE
Exit Sub
End If

Set es=sm.Logon (userid,"userpassword",defaultaps,defaultaut)
If Err.number <> 0 Then
logon_error = " The new user error: THE USER CANNOT LOGON TO CE. Please contact to Burc Kaya."
LoginSuccess = FALSE
Exit Sub
End If

ElseIf (Err.Number = -2147211006) Then
'THE USER PASSWORD DOES NOT MATCH THE GENERIC PASSWORD ("userpassword")
'CREATE A RESPONSE PAGE HERE
LoginSuccess = FALSE
logon_error = "Crystal user error: THE USER CANNOT LOGON TO CE. Please contact to Administrator." Exit Sub

End If

'Set Session("IStore") = es.Service ("", "InfoStore")
Session("IStore") = es.Service ("", "InfoStore")
If ( Err.Number <> 0) Then
logon_error = "InfoStore Error: USER INFOSTORE CANNOT BE CREATED.(System Error) -ES."
LoginSuccess = FALSE
Exit Sub
End If

LoginSuccess = TRUE
End Sub


 
Jennifer -

Send an email to dsom8 at hotmail and I'll forward the files.

- Mike
 
Hi burckaya,
Are you using NT security or Enterprise?

Thanks,
Jennifer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top