I'm trying to connect to a remote desktops active directory.
When I ping the remote desktop I get a response back, so is it possible to connect to it?
Currently, when I connect locally while on the remote desktop, I use the following code: (It works)
PrincipalContext context = new PrincipalContext(ContextType.ApplicationDirectory, "doris-dev", "cn=" + SupplierName + ",cn=suppliers,o=doris");
UserPrincipal user = UserPrincipal.FindByIdentity(context, Username);
I use the same code when I try to remotely connect to the machine, but then the exception message says it needs a username and password. Which username and password is this? Where does it come from?
Related
I'm developing a desktop application using C# language. I'm trying to retrieve all the current active processes on the remote computer with the following code:
else if (infocomboBox.SelectedIndex == 2)
{
string compname = compnameLabel.Text;
Process[] remoteAll = Process.GetProcesses(compnameLabel.Text);
foreach (Process process in remoteAll)
{
ListViewItem item = new ListViewItem(process.ProcessName);
item.Tag = process;
listProcessView.Items.Add(item);
}
}
I put the code inside the button_click function.
I can't seem to retrieve it with an error saying "InvalidOperationException was unhandled"
"Couldn't connect to remote machine"
Log in username and password is disabled on the remote computer. Firewall and antivirus are off also.
Refer below for the error screenshot
Screenshot of the error
What is exactly the problem? Can anybody give solution?
Thank you very much in advance!
I would try to verify from a command line that the hostname is resolvable.
ping theOtherComputerName
If that resolves to an IP address and responds then you've eliminated one possible issue. Next up would have to be connection issues.
I believe the GetProcesses command tries to login to the remote machine using the current username and password, so you would need the same username and password on the other machine,
OR you'll need to impersonate an admin user on the remote machine doing something like this impersonate user in c#
I'm trying to create program in C#, that will retrieve some data from local or remote server. Local part is working great, remote connection does not at all. I'm getting access denied.
Here is the code
public void ConnectToWmi()
{
var options = new ConnectionOptions();
options.Username = "admin";
options.Password = "admin";
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
var scope = new ManagementScope("\\SERVER_NAME\root\cimv2",options);
scope.Connect();
}
I have verified using wbemtest.exe, that connection acctually works.
When I examinated both connections using Wireshark I noticed strange thing - wbemtest is sending correct username "admin" but my program is sending username of current user logged on computer.
So i experimented a little and created administrator account with credentials username "admin" password "admin" on computer that I'm running my program on. And it works!
So in short: Why is my C# program using credentials of currently logged in user instead of credentials that I supplied to it in the code?
more info
server is running as virtual machine in Hyper V on my notebook
client OS is win 8.1, server is win 7
connection between client and server works and all firewalls are disabled
I am not able to find any good documentation on .NET SDK for CyberArk.
I am trying to integrate CyberArk password management system to get password for an Outlook account using the below code
PSDKPasswordRequest passReq = new PSDKPasswordRequest();
PSDKPassword password = null;
// What is the purpose of CredFile??
passReq.CredFilePath = "F:\\CredFiles\\AppUser.cred";
passReq.Safe = "SAFE_NAME";
passReq.Folder = "root";
passReq.Object = userName;
passReq.Reason = "Get some stuff done.";
// Sending the request to get the password
password = CyberArk.AIM.NetPasswordSDK.PasswordSDK.GetPassword(passReq);
However I am not able to connect and getting the following error
"PDKTC006E Failed to connect to provider (Reason=[connect command failed])"\
As I understand it, the API (NetPasswordSDK) is actually a caching service that sits between you and the CyberArk appliance. So you have to configure the service correctly during install as it handles the connection to the CyberArk appliance.
Instructions:
Write down a CyberArk Administrator account's username/password
Write down the CyberArk IP address. This is NOT the web access IP address (PVWA). It's the IP address of the appliance.
On your dev machine, run the CyberArk SDK installer and enter in the IP address and Admin username/password from steps #1 and #2
Assuming the installer completes successfully, it is going to create a user called "Prov_MACHINENAME." (MACHINENAME will equal your NetBIOS hostname) on the CyberArk appliance.
On your dev machine, open C:\Program Files (x86)\CyberArk\ApplicationPasswordProvider\Vault\AppProviderUser.cred and write down the name generated during the install.
Log in to the CyberArk appliance as an administrator
Create a Safe named MySafe
Add the Administrator account from step #1 as a member to MySafe
Add the Prov_MACHINENAME account from step #5 as a member to MySafe
Create an Application named MyApp
Add the Application as a member MySafe
Create an Account named MyAccount and assign it to MySafe
You can now use the following code to connect:
PSDKPasswordRequest objPasswordRequest;
PSDKPassword objPassword;
objPasswordRequest = new PSDKPasswordRequest();
objPasswordRequest.AppID = "MyApp";
objPasswordRequest.Safe = "MySafe";
objPasswordRequest.Object = "MyAccount";
objPassword = PasswordSDK.GetPassword(objPasswordRequest);
password = objPassword.Content;
username = objPassword.UserName;
I'm using the following C#/.Net code on Windows(7/2008/etc) to authenticate users against active directory:
DirectoryEntry entry =
new DirectoryEntry(domainPath, domain + #"\" + username, password);
object obj = entry.NativeObject;
This works for hundreds of users, but not for one. I suspect it's something in the active directory account setup. The user has no problem authenticating on Windows with the exact same credentials or accessing network resources using windows integrated authentication. The user is a sys admin and is also set up as a remote admin.
I am trying to create a new Active Directory user in .net 3.5 and I am recieving the following error "You were not connected because a duplicate name exists on the network."
I have googled the error and I can not find anything related to this on Windows server 2008 and .net 3.5.
I can create a new user when using AD users and groups on the server.
We are using identity impersonate and the user has full access to AD.
I can create the user on my local development machine.
This is on a Windows 2008 server using .net 3.5
Here is the code we are using:
newPassword = GeneratePassword()
ctx = New PrincipalContext(ContextType.Domain, "Domain",containerDistinguishedName)
user = New UserPrincipal(ctx, userName, newPassword, enabled)
' Force the user to change the initial password on first logon
user.ExpirePasswordNow()
' Commit the new object to Active Directory
user.Save()
' Return success
Return newPassword
It sounds like the server may be the thing that is not connected to the domain. This is possibly due to the machine being cloned and reusing the SID or name of the machine. Are you able to manage active directory users from this machine using the active directory users and groups tool?