directoryentry

How to use the objectGUID get a DirectoryEntry?

旧巷老猫 提交于 2019-12-09 19:17:54
问题 I know ,we can get a DirectoryEntry like this: string conPath = "LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com"; string conUser = "administrator"; string conPwd = "Iampassword"; DirectoryEntry de = new DirectoryEntry(conPath, conUser, conPwd, AuthenticationTypes.Secure); and we can change a user's password like this: DirectorySearcher deSearch = new DirectorySearcher(); deSearch.SearchRoot = de; deSearch.Filter = String.Format("sAMAccountName={0}", "xumai"); SearchResultCollection results = deSearch

How I can find a User with the GUID(objectGUID) Parameter in Active Directory

怎甘沉沦 提交于 2019-12-07 01:13:43
问题 In my ASP.NET Application I get Informations from Active Directory. I must get Informations about a User with the GUID Informations (example: a28a6a34dsfdsf57d9e54f945a241) but I don't know how I can use the filter right for this search :/ for example if I search to a User Lastname: DirectoryEntry Entry = new DirectoryEntry("LDAP://" + "Domain"); string filter = "(&(objectClass=user)(objectCategory=person)(cn=" + txtBenutzer.Text + "*))"; DirectorySearcher Searcher = new DirectorySearcher

“new DirectoryEntry(distinguishedName as string)” doesn't work when DN contains a “/”

主宰稳场 提交于 2019-12-06 12:37:33
问题 I have the following code to convert a distinguishedName to a sAMAccountName: Dim de As New DirectoryEntry("LDAP://" & stringDN) Return CType(de.Properties("samaccountname")(0), String) It works great for every DN I pass it, except for one. We have an AD group on our domain that has a "/" in it - call it "Programmers/DBAs". The DN for this group is "Programmers/DBAs,OU=User Groups,DC=mydomain,DC=local". When I try to use this DN as the stringDN above, I get a COMException of "Unknown error

Impersonation and DirectoryEntry

别来无恙 提交于 2019-12-05 05:19:05
I am impersonating a user account successfully, but I am not able to use the impersonated account to bind to AD and pull down a DirectoryEntry . The below code outputs: Before impersonation I am: DOMAIN\user After impersonation I am: DOMAIN\admin Error: C:\Users\user\ADSI_Impersonation\bin\Debug\ADSI_Impersonation.exe samaccountname: My issue seems similar to: How to use the System.DirectoryServices namespace in ASP.NET I am obtaining a primary token. I understand that I need to use delegation to use the impersonated token on a remote computer. I confirmed that the account doesn't have the

Adding a local user to a local group in C#

 ̄綄美尐妖づ 提交于 2019-12-05 04:10:03
问题 I can add a user perfectly well, but then I can't add it to a local group. I get this error:- A member could not be added to or removed from the local group because the member does not exist. Here is the code I'm using. What I am doing wrong? It's just the local machine, I definitely have rights to do it, and the group definifely exists. try { using (DirectoryEntry hostMachineDirectory = new DirectoryEntry("WinNT://" + serverName)) { DirectoryEntries entries = hostMachineDirectory.Children;

How to use the objectGUID get a DirectoryEntry?

痴心易碎 提交于 2019-12-04 16:35:30
I know ,we can get a DirectoryEntry like this: string conPath = "LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com"; string conUser = "administrator"; string conPwd = "Iampassword"; DirectoryEntry de = new DirectoryEntry(conPath, conUser, conPwd, AuthenticationTypes.Secure); and we can change a user's password like this: DirectorySearcher deSearch = new DirectorySearcher(); deSearch.SearchRoot = de; deSearch.Filter = String.Format("sAMAccountName={0}", "xumai"); SearchResultCollection results = deSearch.FindAll(); foreach (SearchResult objResult in results) { DirectoryEntry obj = objResult

How to search Global Catalog (whole forest) using PrincipalContext

柔情痞子 提交于 2019-12-04 02:06:25
问题 myUserList AppUsers = new myUserList(); using (PrincipalContext pcxt = new PrincipalContext(ContextType.Domain, domainName)) { UserPrincipal User = new UserPrincipal(pcxt); User.EmailAddress = emailString; PrincipalSearcher srch = new PrincipalSearcher(User); foreach (var principal in srch.FindAll()) { var p = (UserPrincipal)principal; myUserRow User = AppUsers.NewUsersRow(); User.FirstName = p.GivenName; User.LastName = p.Surname; User.Email = p.EmailAddress; AppUsers.AddUsersRow(User); } }

Adding a local user to a local group in C#

烈酒焚心 提交于 2019-12-03 21:18:06
I can add a user perfectly well, but then I can't add it to a local group. I get this error:- A member could not be added to or removed from the local group because the member does not exist. Here is the code I'm using. What I am doing wrong? It's just the local machine, I definitely have rights to do it, and the group definifely exists. try { using (DirectoryEntry hostMachineDirectory = new DirectoryEntry("WinNT://" + serverName)) { DirectoryEntries entries = hostMachineDirectory.Children; foreach (DirectoryEntry entry in entries) { if (entry.Name.Equals(userName, StringComparison

How to change System.DirectoryEntry “uSNChanged” attribute value to an Int64

烈酒焚心 提交于 2019-12-01 17:37:06
I'm trying to get the Int64 value of a Directory Services object's "uSNChanged" value. Unfortunately, it is always coming back as a COM object of some kind. I've tried using casting to Int64, calling Int64.Parse(), and calling Convert.ToInt64(). None of these work. For a given DirectoryEntry object, this code will display the properties: private static void DisplaySelectedProperties(DirectoryEntry objADObject) { try { string[] properties = new string[] { "displayName", "whenCreated", "whenChanged", "uSNCreated", "uSNChanged", }; Console.WriteLine(String.Format("Displaying selected properties

How to change System.DirectoryEntry “uSNChanged” attribute value to an Int64

旧时模样 提交于 2019-12-01 16:28:35
问题 I'm trying to get the Int64 value of a Directory Services object's "uSNChanged" value. Unfortunately, it is always coming back as a COM object of some kind. I've tried using casting to Int64, calling Int64.Parse(), and calling Convert.ToInt64(). None of these work. For a given DirectoryEntry object, this code will display the properties: private static void DisplaySelectedProperties(DirectoryEntry objADObject) { try { string[] properties = new string[] { "displayName", "whenCreated",