我正在尝试使用以下语句创建计算机的目录条目:
try{
String Path = String.Format("WinNT://{0}", machineName);
DirectoryEntry de = new DirectoryEntry(Path);
de.Username = AdminName;
de.Password = password;
if (de.Guid!= null)
{
Console.Writeline("Exiting the method. Returning the created directory entry for the path = " + de.Path + "and Administrator Account " + de.Username);
}
}
catch (COMException exception)
{
Console.WriteLine("Got the exception"+exception.Message);
throw new Exception(exception.Message);
}
这里我使用的是Administrators组成员的用户登录。同样凭借相同的凭据,我可以远程桌面到系统。我收到类型UnauthorizedAccessException的以下错误:
"Access is denied"