Login Cart  Cart
logo

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Offline zuvefox  
#1 Posted : Wednesday, July 6, 2011 8:21:54 AM(UTC)
zuvefox
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 moderator Thursday, July 7, 2011 8:56:48 AM(UTC)  | Reason: added solved to title

Offline ErikC  
#2 Posted : Wednesday, July 6, 2011 12:16:31 PM(UTC)
ErikC
Rank: Administration

Joined: 2/26/2008(UTC)
Posts: 1,196
Netherlands
Location: Amsterdam

Thanks: 56 times
Was thanked: 98 time(s) in 84 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 6, 2011 12:27:36 PM(UTC)  | Reason: typo

Uses Visualcron since 2006.
Offline zuvefox  
#3 Posted : Thursday, July 7, 2011 5:50:55 AM(UTC)
zuvefox
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
Offline ErikC  
#4 Posted : Thursday, July 7, 2011 7:11:56 AM(UTC)
ErikC
Rank: Administration

Joined: 2/26/2008(UTC)
Posts: 1,196
Netherlands
Location: Amsterdam

Thanks: 56 times
Was thanked: 98 time(s) in 84 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! Cool
Erik

Edited by user Thursday, July 7, 2011 7:14:35 AM(UTC)  | Reason: extra info added

Uses Visualcron since 2006.
Offline Support  
#5 Posted : Thursday, July 7, 2011 8:09:02 AM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,625

Thanks: 338 times
Was thanked: 201 time(s) in 192 post(s)
Originally Posted by: zuvefox Go to Quoted Post
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:
            TaskClass t = new TaskClass();
            t.TaskType = TaskClass.TaskT.HTTP;
            t.CreateTaskTypeObject();
            t.HTTP.NetworkCredential = "NetworkCredentialId";


or
Code:

            TaskClass t = new TaskClass();
            t.TaskType = TaskClass.TaskT.HTTP;
            t.HTTP = new TaskHTTPClass();
            t.HTTP.NetworkCredential = "NetworkCredentialId";
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
Offline zuvefox  
#6 Posted : Thursday, July 7, 2011 8:37:18 AM(UTC)
zuvefox
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
Offline Support  
#7 Posted : Thursday, July 7, 2011 8:38:23 AM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,625

Thanks: 338 times
Was thanked: 201 time(s) in 192 post(s)
Originally Posted by: zuvefox Go to Quoted Post
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?
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
Offline zuvefox  
#8 Posted : Thursday, July 7, 2011 8:45:10 AM(UTC)
zuvefox
Rank: Member

Joined: 3/28/2011(UTC)
Posts: 24
Location: Indonesia

yess. worked :)
Users browsing this topic
Guest
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.

footer
Follow VisualCron on Facebook Follow VisualCron on Twitter   Join the VisualCron group on LinkedIn neteject.com anyconnect.net millimetrics.com xendapp.com