Assign Permission programattically

  • 16 November 2005
  • 5 replies
  • 0 views

Badge +8
Hi

I got this code from this forum itself. I goes something like this.

Public oK2Manager As K2Mng.K2Manager
Public oProcSet As K2Mng.ProcessSet


' To Assign Permissions
Dim oPermissions As New K2Mng.Permissions
Dim oProcSetPermissions As New K2Mng.ProcSetPermissions
oProcSetPermissions.ProcessName = "Test"
'oProcSetPermissions.ProcSetID = myProc.ID

oProcSetPermissions.UserName = myProc.DataFields.Item("Manager").Value
oProcSetPermissions.Admin = True
oProcSetPermissions.Start = True
oProcSetPermissions.View = True
oProcSetPermissions.ViewPart = True
oProcSetPermissions.ServerEvent = True
oPermissions.Add(oProcSetPermissions)
---> oK2Manager.UpdateProcUserPermissions(oProcSet.ProcSetID, oPermissions)


I did reference k2mng in my project. But it throws error when i run aspx page that has this code error it throws is "Object reference not set to instance of an object " at last line of code.


Suggestion Please ?

5 replies

Badge +8
I Think Problem lies in this line..

oProcSet.ProcSetID

From where do i get this procsetid.

I am setting permission while starting a process from apsx page.
Suggestions ?
Badge +8
Any Help ?
Badge +11
Have you instantiated your oK2Manager object? Is see you've declared it but from the code you've posted, it's not instantiated with a the NEW keyword.

Also, you need to call the Login method of the K2Manager class before you can use it...



'oK2Manager.Login(strK2ServerName, intPort, ConStr)
oK2Manager.Login(strK2ServerName, intPort)
'###########################################


Hope this helps,
Ockert
Badge +8
God Bless you man

Thanks a lot ...solved it. I looked up k2mng namespace in my help file but could not find any sort of details. I was missing connection part.

Though i fixed it as

oK2Manager.UpdateProcGroupPermissions(oProcSet.ProcSetID, oPermissions)

I think the first argument in this function is the process id. I supplied by looking up in db, but just curious is there any way where i can get collection of all the process in server..

Thanks in advance
Badge +11
Glad I could help...

The first argument is actually the ProcessSetID. How it works is...
A process set contains 1 or more versions of the same process each having a unique ProcessID. Each ProcessID in turn contains 0 or more process instances started - each one having its own ProcessInstanceID.

i.e.

ProcSetID
* ProcID (first version of process)
- ProcInstID
- ProcInstID
- ...
* ProcID (second version of process)
- ProcInstID
* ProcID (third version of process)
* ...


Use the K2Manager.GetProcSets method to return a collection of Process Sets

Hope this helps,
Ockert

Reply