Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: COMException: "(37,8):LogonType" when changing user

$
0
0

OK so I downloaded the source and put a break point in TaskFolder.cs (line 254);

 

if (v2Folder != null)returnnew Task(this.TaskService, v2Folder.RegisterTaskDefinition(Path, definition.v2Def, (int)createType, UserId, password, LogonType, sddl));

 

 

The issue is seemingly stemming from the parameter UserId. When in the editor, I entered a new user to run the task, say,myDomain\jsmith. The field in the editor is populated with the friendly name, e.g.John Smith, and it is this value that ends up being submitted by the editor to the above constructor. The problem is, it should have been the fully qualified username, myDomain\jsmith.

Tracking this back further, the source of the "friendly" username is in NativeMethods;

 

publicstaticbool SelectAccount(System.Windows.Forms.IWin32Window parent, string targetComputerName, refstring acctName, outbool isGroup, outbool isService)
{
	CubicOrange.Windows.Forms.ActiveDirectory.DirectoryObjectPickerDialog dlg = new CubicOrange.Windows.Forms.ActiveDirectory.DirectoryObjectPickerDialog();
	dlg.TargetComputer = targetComputerName;if (dlg.ShowDialog(parent) == System.Windows.Forms.DialogResult.OK)
	{if (dlg.SelectedObject != null)
		{
			acctName = dlg.SelectedObject.Name;
			isGroup = dlg.SelectedObject.SchemaClassName.Equals("Group", StringComparison.OrdinalIgnoreCase);
			isService = NativeMethods.AccountUtils.UserIsServiceAccount(acctName);returntrue;
		}
	}
	isGroup = isService = false;returnfalse;
}

 

The line acctName = dlg.SelectedObject.Name is where the name is set and eventually makes its way to the RegisterTaskDefinition call.

Now, I am no expert in this area, so apologies if this suggestion is nonsense, but the propertydlg.SelectedObject.Upn seems like it might do the trick instead ofName.

I made this change locally and I now seem able to change my users as expected. I haven't gone as far as actually trying to run the tasks yet, but I'll look at that now and report back on whether it was actually successful.

 


Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>