userprincipal

UserPrincipal.FindByIdentity results in COM error 0x80005000

元气小坏坏 提交于 2021-02-07 20:34:49
问题 I've an MVC Intranet app that I've recently upgraded from .Net 4 to 4.6.1. This app queries user details from Active Directory to load details that aren't available in the Controller's User.Identity property and until lately has done so flawlessly. The code looks something like this: public static void foo() { var usr = LookupUser("MyDomain", "jbloggs"); ... } private static UserPrincipal LookupUser(string domain, string username) { Console.WriteLine($"Lookup {domain}\\{username}"); using

UserPrincipal.FindByIdentity results in COM error 0x80005000

孤街醉人 提交于 2021-02-07 20:34:27
问题 I've an MVC Intranet app that I've recently upgraded from .Net 4 to 4.6.1. This app queries user details from Active Directory to load details that aren't available in the Controller's User.Identity property and until lately has done so flawlessly. The code looks something like this: public static void foo() { var usr = LookupUser("MyDomain", "jbloggs"); ... } private static UserPrincipal LookupUser(string domain, string username) { Console.WriteLine($"Lookup {domain}\\{username}"); using

Editing registry value for newly created user

删除回忆录丶 提交于 2020-01-15 04:52:59
问题 I have a .NET application that creates a new local user like so: var principalContext = new PrincipalContext(ContextType.Machine); var userPrincipal = new UserPrincipal(principalContext); userPrincipal.Name = StandardUserName.Text; userPrincipal.Description = "New local user"; userPrincipal.UserCannotChangePassword = true; userPrincipal.PasswordNeverExpires = true; userPrincipal.Save(); // Add user to the users group var usersGroupPrincipal = GroupPrincipal.FindByIdentity(principalContext,

asp.net application userprincipal.findbyidentity works with browser on server, throws exception from my machine

前提是你 提交于 2020-01-04 15:13:53
问题 I have an application that is running on an IIS 7 server, in this program I need to find all the groups that the current user is a member of. When I access the website using the browser on the server, it works perfectly, but when I try to access it from my machine it keeps throwing a COM exception, Here is the code I'm using to get the user groups. private List<string> GetUserGroups(string userName) { //The list of strings for output. List<string> output= new List<string>(); try { //creating

ASP.NET MVC Windows Authentiaction and DirectoryServices - Get Mail Address of the current user throws an InvalidCastException

 ̄綄美尐妖づ 提交于 2020-01-01 11:55:16
问题 I am using ASP.NET MVC 4 and Windows Authentication. When I am using VisualStudio everything works fine, but when I deploy my site an exception is thrown. var emailAddress = UserPrincipal.Current.EmailAddress; throws: Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'. The rest works fine. Users can authenticate and I can get the users name etc. EDIT: I enabled Impersonation on IIS. Now I

Is there a way to set a new user's domain suffix through the UserPrincipal class?

谁都会走 提交于 2019-12-24 13:42:47
问题 through the UserPrincipal Class I can set the UserPrincipalName and thus when my user is created the first part of the User logon name is populated: up.UserPrincipalName = "ryan.anthony3"; produces the following result: however that drop down is empty unless I choose one of the options through the interface I'd like to set one of the available options programmatically using this UserPrincipal class if possible... is that possible? I am not seeing a setter for it here: http://msdn.microsoft

What is WCF userPrincipalName value attribute format for using a local account?

折月煮酒 提交于 2019-12-24 07:06:20
问题 assuming the local account name is "JohnDoe" & the local machine name is "Development"... In a clear, unambiguous functional example what should the value for userPrincipalName be? <identity> <userPrincipalName value="WHAT GOES HERE IF USING A LOCAL ACCOUNT?" /> </identity> 来源: https://stackoverflow.com/questions/13941645/what-is-wcf-userprincipalname-value-attribute-format-for-using-a-local-account

How to search for users in Global Catalog within AD forest with multiple trees

和自甴很熟 提交于 2019-12-18 04:55:17
问题 I have the following AD forest with two trees: Domain1. Has two child domains Domain2 and Domain3 Domain4. Doesn't have child domains. DNS name of the Domain1 is domain1.local . DNS name of the Domain4 is domain4.local . In each domain there is a domain controller with Global Catalog enabled. I'm trying to get UserPrincipal for the user from Domain 4 by its SID. The program runs from a machine in Domain2. I use the following code: // Running on some machine from Domain2 PrincipalContext

HttpClient set credentials for Kerberos authentication

旧巷老猫 提交于 2019-12-17 15:44:49
问题 I am trying to authenticate with a kerberos/HTTP host. Using Apache HttpClient as my client - and a slightly modified version of this source. My Kerberos authentication goes perfectly fine, and I wish to know how to set the login credentials programatically. At the moment, the credentials are entered manually through the console, but I want to have it chosen by me at run time. [ As I wish to automate and load test the server with a large number of users, actually. ]. EDIT : Here is a code