'Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
Connecting with ContextType.Domain work fine, but I need to connect to the domain controller to get the last successful logons. When I use a domain user (even if they are in the domain admins group) I get an Access is denied error with the above code.
According to your description, this exception means the user which you using to login the domain controller had been established more connection with the server, and the connection amount is out of the limit connection amount in windows.
To resolve this problem, you could restart the "Workstation" service on the domain server.
Note: The "Workstation" service manages shared resource connections. Restarting the service will force a release of the network connection. Because of this, however, there are multiple dependent services, so I suggest you’d better wait for auto release
the network connection by the service.
Or you could try to use servername to instead IP, see the following code:
using (var context = new PrincipalContext(ContextType.Machine, "server_name_of_domain_controller", null, ContextOptions.Negotiate, "domain_name\\administrator", "password"))
If you have any other questions, please feel free to contact me any time.
Thanks for the help. Before trying the Workstation solution, do you know why a user who is in the domain admins group is getting Access is denied, where as the domain administrator does not. Is there a group the user needs to be in?
If the account is in domain admins groups, the account has enough permission to access the domain, for more details about this issue, you could refer to the following link.
None
0 Points
12 Posts
PrincipalContext error
Jun 14, 2017 10:41 AM|dannyg_uk|LINK
using (var context = new PrincipalContext(ContextType.Machine, "ip_address_of_domain_controller", null, ContextOptions.Negotiate, "domain_name\\administrator", "password"))
Results in:
System.DirectoryServices.AccountManagement.PrincipalOperationException:
'Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
Connecting with ContextType.Domain work fine, but I need to connect to the domain controller to get the last successful logons. When I use a domain user (even if they are in the domain admins group) I get an Access is denied error with the above code.
Cheers
Danny
Member
520 Points
286 Posts
Re: PrincipalContext error
Jun 15, 2017 09:05 AM|EvenMa|LINK
Hi danny_uk,
According to your description, this exception means the user which you using to login the domain controller had been established more connection with the server, and the connection amount is out of the limit connection amount in windows.
To resolve this problem, you could restart the "Workstation" service on the domain server.
Note: The "Workstation" service manages shared resource connections. Restarting the service will force a release of the network connection. Because of this, however, there are multiple dependent services, so I suggest you’d better wait for auto release the network connection by the service.
Or you could try to use servername to instead IP, see the following code:
If you have any other questions, please feel free to contact me any time.
Best Regards
Even
None
0 Points
12 Posts
Re: PrincipalContext error
Jun 15, 2017 10:51 AM|dannyg_uk|LINK
Hi Even
Thanks for the help. Before trying the Workstation solution, do you know why a user who is in the domain admins group is getting Access is denied, where as the domain administrator does not. Is there a group the user needs to be in?
Cheers
Danny
Member
520 Points
286 Posts
Re: PrincipalContext error
Jun 19, 2017 07:18 AM|EvenMa|LINK
Hi dannyg_uk,
As far as I know, domain admins groups are the member of administrators groups, about this question, you could refer to the following link.
https://social.technet.microsoft.com/Forums/en-US/98b23d0c-e9d0-447e-9a91-317451266d75/difference-between-domain-admins-builtin-administrators-group-?forum=winserverDS
If the account is in domain admins groups, the account has enough permission to access the domain, for more details about this issue, you could refer to the following link.
https://technet.microsoft.com/en-us/library/dn579255(v=ws.11).aspx#About Active Directory groups
If you have any other questions, please feel free to contact me any time.
Best Regards
Even