VisualCron
»
Support
»
API
»
[solved] Network Credential
 Rank: Member
Joined: 3/28/2011(UTC) Posts: 24 Location: Indonesia
|
hi.. how to change or set network credential on TASK using visualcron API ? I used: Dim j As New JobClass() j.Name = "Shutdown" j.Task("[TaskID]").Execute.NetworkCredential="[Credential Name]" but result error with error description: Obect Reference not set to an instance of an object thanx Edited by user Thursday, July 07, 2011 8:56:48 AM(UTC)
| Reason: added solved to title
|
|
|
|
|
|
 Rank: Advanced Member
Joined: 2/26/2008(UTC) Posts: 1,103  Location: Amsterdam, The Netherlands Thanks: 39 times Was thanked: 65 time(s) in 56 post(s)
|
Hi zuvefox, To set the credentials to a task you need the right credential key. The server object holds all the credentials and their keys. They are strings. So look there for the right string. Every task is specific in doing something, like an HTML task. The task object should have a lot of properties in the HTML section of the task. In there you will find credential settings where you can set the credential, like: Code:
Server s = new Server();
TaskClass t = new TaskClass();
...
t = s.Jobs.Tasks.Get("qwertyuio-asdf-zxcv-1234-poiuytrreewwq");
t.HTTP.NetworkCredential = "1234567-abcd-1234-abcd-1234567890ab";
s.Jobs.Tasks.Update(t);
Regards, Erik Edited by user Wednesday, July 06, 2011 12:27:36 PM(UTC)
| Reason: typo |
Uses Visualcron since 2006. |
|
|
|
|
|
 Rank: Member
Joined: 3/28/2011(UTC) Posts: 24 Location: Indonesia
|
thanx for your response
I also get same error when i run that code. error on t.HTTP.NetworkCredential = "1234567-abcd-1234-abcd-1234567890ab"; with error message: Object reference not set to an instance of an object.
credential key I got from networkcredentials.xml on tag <Id>
thanx
|
|
|
|
|
|
 Rank: Advanced Member
Joined: 2/26/2008(UTC) Posts: 1,103  Location: Amsterdam, The Netherlands Thanks: 39 times Was thanked: 65 time(s) in 56 post(s)
|
Hi zuvefox, It's ok to get the key from the networkcredentials.xml file. That's the same key I refer to in my previous post. I gave an example of a HTTP task. I do not know which type your task is, but you might need a different approach: Code:
t.TASKTYPE....Credential = "1234567-abcd-1234-abcd-1234567890ab";
Please use the intellisense in Visual Studio to find your task type. You can also use a breakpoint on this line an look in the Locals window for you t variable. Expand this and see where the tasktype is filled. (A lot of tasktypes have the value null, you can skip these) Expand this and you might see your credential settings there. Use the full path to the credential and you have your code line. Success guaranteed! Erik Edited by user Thursday, July 07, 2011 7:14:35 AM(UTC)
| Reason: extra info added |
Uses Visualcron since 2006. |
|
|
|
|
|
 Rank: Administration
Joined: 2/23/2008(UTC) Posts: 6,120  Location: Sweden Thanks: 198 times Was thanked: 117 time(s) in 112 post(s)
|
Originally Posted by: zuvefox  thanx for your response
I also get same error when i run that code. error on t.HTTP.NetworkCredential = "1234567-abcd-1234-abcd-1234567890ab"; with error message: Object reference not set to an instance of an object.
credential key I got from networkcredentials.xml on tag <Id>
thanx Which object is null? If HTTP object is null you need to create a HTTP object like this: Code:
or
[code=csharp]
TaskClass t = new TaskClass();
t.TaskType = TaskClass.TaskT.HTTP;
t.HTTP = new TaskHTTPClass();
t.HTTP.NetworkCredential = "NetworkCredentialId";
|
|
|
|
|
|
|
 Rank: Member
Joined: 3/28/2011(UTC) Posts: 24 Location: Indonesia
|
I got
I use task system shutdown so script should:
tc.SystemShutdown.Credential = "bb4baeb9-0b0d-4526-8975-c13d1b123456"
:) thanx for your information
|
|
|
|
|
|
 Rank: Administration
Joined: 2/23/2008(UTC) Posts: 6,120  Location: Sweden Thanks: 198 times Was thanked: 117 time(s) in 112 post(s)
|
Originally Posted by: zuvefox  I got
I use task system shutdown so script should:
tc.SystemShutdown.Credential = "bb4baeb9-0b0d-4526-8975-c13d1b123456"
:) thanx for your information Ok, so it works now? |
|
|
|
|
|
|
 Rank: Member
Joined: 3/28/2011(UTC) Posts: 24 Location: Indonesia
|
|
|
|
|
|
|
| Users browsing this topic |
|
Guest
|
VisualCron
»
Support
»
API
»
[solved] Network Credential
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.