LDAP CN as a container - active-directory

I was running a script to pull back LDAP paths, and I noticed that some DN has 2 CN entries eg
CN=User1,CN=Users,DC=....
CN=User1,CN=Users,DC=....
I was wondering if this was possible to have set up inside AD, and if it is then why would a OU not be used instead of 2 CN's. I was under the impression that best practice would be to only have 1 CN as the terminal object.
Thanks for reading.

Those user DN's you show are in the built-in Users container. Note they are a container, not an OU. Thus, they are indicated in a distinguished name with "CN".
An OU is indicated with "OU".
The difference between a container and OU was answered here, but in short, the only difference really is that you cannot specify group policies on containers (but they do inherit policies).

Related

Getting to connect users with an ldap with two groups

I have an application with which I would like to connect my ldap users.
I want two types of users to be able to log in: internal and external.
In the application that I deploy, three parameters are taken into account (ldapjs protocol, scope sub)
export LDAP_FILTER LDAP_BASEDN LDAP_UIDTAG
How do I get
"OU=Internal,OU=Users,DC=test,DC=example,DC=com"
and
"OU=External,OU=Users,DC=test,DC=example,DC=com"
members to connect to it?
How should I fill in these parameters knowing that the cn is username ?
Thank you for your help
I tried
export LDAP_FILTER (|(&(ou=Internal)(cn={{username}}))(&(ou=External)(cn={{username}}))
and many more
Those are OU's (organizational units) not groups. You cannot filter by OU in an LDAP filter. You use the Base DN to limit results to one OU. However, you can only use one.
You may be better off creating a group and adding all of the users from both OUs into that group, and then you can filter on the group, like this:
(memberOf=CN=MyAppGroup,OU=Groups,DC=test,DC=example,DC=com)
That should be the full distinguishedName of the group.

Department field in AD Computer Object?

I have a Powershell script that will import a csv file containing a list of computers and their respective owners, and then perform some queries on each. I am looking for a reliable way of maintaining this list so it's up-to-date and can be exported for Powershell consumption.
One idea, is that all of our computers in AD have their own respective OUs, and I am looking to use a field (Department if there is one) that will then be populated with the IT Owner. For example, in the Computers OU, there will be child OUs: "Finance Servers"; "Marketing Servers", etc. We can't use Description as this is already used.
Any ideas as I can't see additional fields or custom fields to play around with for each computer object?
Thanks
My recommendation would be to use the "ManagedBy" Property, however if you prefer to look over the options for yourself you can always open up powershell and run
get-adcomputer -identity "SomeServerName" -properties *
that will show you all properties that are available on that object.

What does dsget use to query the directory?

I am in an organization with an Active Directory with a very deep nested group structure. I would like to query the directory to recursively find user members of a group from a Linux machine. On a Windows machine,
dsget group "dn_of_group" -members -expand
does exactly what I want and does it very quickly. When I tried to get the same results via LDAP with
(memberOf:1.2.840.113556.1.4.1941:=dn_of_group)
the query takes almost a minute to run. Does dsget use LDAP under the hood or does it use some other means to query the directory? And if so, is there any way for me to also use that?
Edit:
Clarified that I need the members which are users.
The framework 3.5 with System.DirectoryServices.AccountManagement Namespace provides a method that searches all groups recursively and returns the groups in which the user is a member. The returned set may also include additional groups that system would consider the user a member of for authorization purposes.
UserPrincipal.GetAuthorizationGroups()
The groups that are returned by this method may include groups from a different scope and store than the principal. For example, if the principal is an AD DS object that has a DN of "CN=SpecialGroups,DC=Fabrikam,DC=com, the returned set can contain groups that belong to the "CN=NormalGroups,DC=Fabrikam,DC=com
In the other direction you've got :
GroupPrincipal.GetMembers(bool recursive)
See Remarks

Generate objectSID for LDIFDE import

i'm writing an AD sync tool, which takes an LDIF file exported from an AD A, applies some replaceing and skip rules and creates another LDIF file that can then be applied to an AD B.
During the creation, i have read access on the AD B, so i can get the Schema to know what attribute-value pairs i can or can not set, and to see if there are allready objects that already exist in B that i only have to modify , but not to create. So far so good.
Right now, my rules do not copy the objectSid (and others), since they won't be right. As far as i checked, a SID is always composed of the domainSid and and an ID, like SOME-DOMAIN-SID-513 which is the SID of the Domain Users of that domain.
So IDs < then 1024 seem to be reserved for internal use while IDs > 1024 will be part of objects that where created on the way.
My question is now, can i create own objectSIDs for new entries that i want to create and set them in the LDIF file?
Any hints on that?
I don't think you can. I'm intrigued as to why you'd want to.

Why isn't manager attribute changing on distinguished name modification in Sun Directory Server 6.3?

I have a problem with manager attribute in Sun Directory Server.
I set this attribute for a user in the directory, e.g. cn=testmanager,dc=test,dc=com and when I change manager's dn this change is not propagated in manager attributes.
For example:
I have two users:
dn: cn=testmanager,dc=test,dc=com
and
dn: cn=testperson,dc=test,com
manager: cn=testmanager,dc=test,dc=com
Then I modify manager's dn to:
dn: cn=testmanagerchange,dc=test,dc=com
But manager attribute in cn=testperson,dc=test,com doesn't change is still equal to cn=testmanager,dc=test,dc=com. In Active Directory it works fine.
Exact definition of attribute:
Name: manager
OID: 0.9.2342.19200300.100.1.10
Aliases: -
Origin: RFC 1274
Description: Standard LDAP attribute type
Syntax: 1.3.6.1.4.1.1466.115.121.1.12 (DN)
Multivalued: Yes
This may not directly help, but it may depend on how Sun Directory Server handles DN syntax attributes. I can speak with experience for eDirectory, where DN syntax attributes do what you want automagically.
I.e. You can rename, move, or delete an object, and all DN syntax references to it will automatically update themselves. (Actually for renames and moves they do not actually update, rather when they convert the internal database ID value for the object to display the pretty human readable name, it always shows the current value. Clean up after deletes are handled differently).
The question becomes, how does Sun Directory Server handle these cases.
Though it is interesting that manager can be multivalued. That would suck, having several managers!
I found the answer.
In Sun Directory Server you have to set the list of attributes that should keep reference integrity. Some attributes are set by default, however you have to manually add manager attribute.
This is an article that explains this issue: http://docs.sun.com/app/docs/doc/820-2763/fsush?a=view.
Thanks for your help.

Resources