C
C#2y ago
ChuPapi

Active Directory Programming

So, I've been given a WPF assignment from school, and this is the description of how it should work: When the "Export DB information to AD" button is clicked, you need to do the following: Read the OUs table (via DBQuery.GetDBOUs()) If this OU doesn't exist in AD, create it and display in the lstFeedback listbox which OU you have added. If this OU already exists, only display in the lstFeedback listbox that you haven't added this OU. Read the Groups table (via DBQuery.GetDBGroups()) If this Group doesn't exist in AD, create it and display in the lstFeedback listbox which Group you have added. If this Group already exists, only display in the lstFeedback listbox that you haven't added this Group. Read the Users table (via DBQuery.GetDBUsers()) If this User doesn't exist in AD, create it and display in the lstFeedback listbox which User you have added. If this User already exists, only display in the lstFeedback listbox that you haven't added this User. Read the GroupMemberships table (via DBQuery.GetDBGroupMemberships()) If the User is not yet added to the Group, add them and indicate this in the lstFeedback listbox. If the User is already added to the Group, also display this in the lstFeedback listbox. I have already implemented the first three foreach loops, and they are working fine. However, in the last loop, users need to be added to groups, and I have written the code for that, but I keep getting errors. The first one is "Failed to add user to group. Error: An invalid DN syntax has been specified." So, I thought of adding "OU=" in my code, like this: string groupDN = $"{ADContext.contextLDAPPrefix}OU={group.OUId},{ADContext.contextRootDomain}"; But when I add this, I get the error "Failed to add user to group: The object does not exist on the server." However, if I remove the "OU=" part, it goes back to the previous error. It's like playing ping-pong, and I don't know how to fix it.
2 Replies
ChuPapi
ChuPapiOP2y ago
ChuPapi
ChuPapiOP2y ago
Just to show what the code looks like for each error
Want results from more Discord servers?
Add your server