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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to populate Imp Catalog User classes w/acc manager

Status
Not open for further replies.

slaforce

Programmer
Jul 29, 2002
77
US
Hi -
I'm trying to populate my imp catalog user classes with access manager userclasses using the following macro. I get the message 'User Profiles have been successfully created', but when I look in my catalog - the user classes are not there. Thank you for your help.:


Copy User classes from a namespace to catalog User Profiles. ' '--------------------------------------------------------------'
OPTION EXPLICIT

Declare Sub User_classes(UsrClass as object, UsrProfile as object)

Sub Main ()

DIM ObjAuthApp as object
DIM ObjAuthDoc as object
DIM ObjUserClass as object
DIM ObjImpApp as object
DIM ObjCatalog as object
DIM ObjUserProfile as object
DIM ObjImpCat as object

On Error Goto Errhdlr1

'Open Namespace
Set ObjAuthApp = CreateObject("Authenticator2.Application")
Set ObjAuthDoc = ObjAuthApp.Documents.OpenWithBasicSignon ("default", "administrator","","Root User Class")

'Open catalog
Set ObjImpApp = CreateObject("CognosImpromptu.Application")
ObjImpApp.OpenCatalog "C:\dev.CAT", "Creator"
Set ObjImpCat = objImpApp.ActiveCatalog

Set ObjUserClass = ObjAuthDoc.rootuserclass
Set ObjUserProfile = ObjImpCat.ActiveUserClass

Call User_classes(ObjUserClass, ObjUserProfile)

MsgBox "User Profiles have been successfully created"

ObjImpApp.Quit
ObjAuthApp.quit

Set ObjImpApp = Nothing
Set ObjUserClass = Nothing
Set ObjAuthDoc = Nothing
Set ObjAuthApp = Nothing

exit sub

Errhdlr1:
Msgbox "Error - " & Err & ": " & Error$

End Sub

'--------------------------------------------------'
' User_classes function: '
' Navigates the Userclass hierarchy of Namespace '
' and create User Profiles in the catalog ' '--------------------------------------------------'

Sub User_classes(UsrClass as object, UsrProfile as object)

Dim ObjUsrClass as object
Dim ObjUsrProfile as object
Dim ObjMasterClass as object
Dim ObjMasterProfile as object
Dim UserClassCount as Integer

Set ObjUsrClass = UsrClass
Set ObjUsrProfile = UsrProfile
Set ObjMasterClass = UsrClass
Set ObjMasterProfile = UsrProfile
UserClassCount = ObjUsrClass.userclasses.count

If ObjUsrClass.userclasses.count <> 0 then
For UserClassCount = ObjUsrClass.userclasses.count to 1 step -1

Set ObjUsrClass = ObjMasterClass.userclasses.Item(UserClassCount)
Set ObjUsrProfile = ObjMasterProfile.userclasses.add
(ObjUsrClass.name)
Set objUsrprofile=Nothing
Next UserClassCount
End If

Set ObjUsrClass = Nothing
Set ObjMasterClass = Nothing
End Sub

----------------------
 
odd, just tried it on a test catalogue and it works fine (7MR2).
If you step through it with F8 and have and F2 variable window open, does it show a UserClassCount figure?

&quot;Time flies like an arrow, but fruit flies like a banana.&quot;
 
Thanks drlex -

I finally got it to work. I ran it again and it worked fine the second time. Do you know if there is a way to pull in sub userclasses into the catalog also. This macro is just pulling in userclasses that are under the root userclass. What if I need the next level down also?

Thanks for your help.
 
'fraid I don't know, as I only have one level (under root), but suspect that .ChildUserClasses property would be where to go next, nested in the above macro.
lex

&quot;Time flies like an arrow, but fruit flies like a banana.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top