Set unix attribute in Active Directory using variables - active-directory

How can I set UID, GID & home directory value relatively, in Active Directory under unix attributes tab?
For example, instead of writing:
/home/ann.white
/home/marie.jones
/home/Jessica.Cox
I want to format like this:
/home/%u
For all 300 user in Active Directory, I tried with %u but it returns user relative identifier (RID), so what is the variable for username & group relative identifier?

%<givenName>.%<sn>
http://www.kouti.com/tables/userattributes.htm <- sorry it's 3rd party, the table is huge and MS doesn't seem to have one available on their website.

Related

How to get all groups of members who distinguishedName begins with something

My requirement is to get all the groups of users whose distinguishedName begins with say Auser*.
So, I created a filter in Apache Directory Studio
(&
(objectClass=group)
(member=CN=Auser*)
)
However, to my surprise, this does not return any results. If I change this to a particular user's distinguishedName, I am able to get results
(&
(objectClass=group)
(member=CN=AUser10,OU=Mygrp,DC=domain,DC=com)
)
Am I missing something ?
member has Distinguished-Name-Syntax, and given it's Active Directory you are trying to search, you can't have substring matching as in a normal Directory-String attribute like cn.
Why don't you just reverse your search strategy? Do a subtree search on your domain with filter (&(objectClass=user)(cn=userprefix*)) retrieving attribute memberOf, export to CSV, remove duplicates, done.
Please try this one :
(&
(objectCategory=group)
(name=Auser*)
)
distinguished name is long name containing full path + name. like : CN=Username,OU=internalFolder,OU=parentFolder,DC=domainComponentName,DC=com
For filtering by name just search on the name or other attributes you want like givenName

What is the proper way to get some specific user attributes from Active Directory via LDAP C API?

I am trying to get some user attributes from Active Directry using Windows LDAP API. I am using:
Active Directory Version: The one that comes with Windows Server 2012
LDAP version: 3
Wldap32.lib version: The one that comes with Windows 10 x64
Eg:
PCHAR myAttributes[4];
myAttributes[0] = "DistinguishedName";
myAttributes[1] = "DisplayName";
myAttributes[2] = "PasswordExpired";
myAttributes[3] = "mail";
ldap_search_s(
myLdapConnection, // Ldap connection
myDomain, // DN to start search
LDAP_SCOPE_SUBTREE, // Scope
myFilter, // Filter
myAttributes, // Retrieve list of attributes
0, // Get both attributes and values
&mySearchResult // [out] Search results
);
It returns DistinguishedName, DisplayName and mail attributes, but does not reuturn the PasswordExpired attribute.
I queried with some other attributes and it looks like it does not return attributes with boolean values as well as the EmailAddress attribute.
Why does it not return PasswordExpired attribute?
What about EmailAddress ?
Is there a difference between EmailAddress and mail ?
There is no PasswordExpired LDAP attribute in Active Directory. To build your query look at this URL for attribute names in standard Active Directory schema https://msdn.microsoft.com/en-us/library/ms675090(v=vs.85).aspx. To check if password for given account is expired you'll need to check userAccountControl attribute, which is actually value storing flags of different states of user account https://msdn.microsoft.com/en-us/library/ms680832(v=vs.85).aspx. There is IADsUser interface that will translate this all for you in case you don't have to stick just to LDAP https://msdn.microsoft.com/en-us/library/aa746343(v=vs.85).aspx
You will find current primary email address in mail attribute. There is no EmailAddress LDAP attribute, unless you meant E-mail-Addresses which is CN for the same schema attribute as mail, so no difference there.
See above. In general if you do not have compelling reason to stick just to C/LDAP I'd recommend you to use .Net Framework instead. Otherwise you have a lot of work ahead of you - not just interpreting bit flags like in case of password expiration but possibly also with different authentication methods, different structures capturing time and date, accounting for timezones, UTF, chasing referrals and other stuff you might need depending on complexity of what you want to achieve. You will be productive much faster in .Net Framework. See DirectoryServices https://msdn.microsoft.com/en-us/library/mt481534(v=vs.110).aspx namespace or Security namespace https://msdn.microsoft.com/en-us/library/mt481561(v=vs.110).aspx for details.

How to change computer's canonical/displayed name in Active Directory?

I have an AD with 71 computers.
However, there are actually less than 50 physical computers, so I'm doing some cleanup. But, up until now when renaming PC's, I've only renamed them at the workstation through Control Panel->System.
So, the displayed name of computers in AD does not match the workstation's computer name. The displayed name, the "Canonical name of object" under Properties->Object, and the cn attribute in Attribute Editor are all the old name, while the "Computer name" and "DNS name" under Properties->General are the updated name also found at the workstation.
How do I reconcile the two different sets of names for each computer? I cannot edit the "Canonical name of object" in Properties, nor can I edit the cn attribute:
Operation failed. Error code: 0x2016; The directory service cannot
perform the requested operation on the RDN attribute of an object.
00002016: Modify of RDN 'CN' on CN=COMP,OU=TEST,DC=DOMAIN,DC=local not
permitted, must use 'rename operation instead.
Going forward, what is the proper way to rename a PC so that it updates both at the workstation and throughout AD?
There is a command line available (reference here: https://technet.microsoft.com/en-us/library/cc788029.aspx) that people will use to automate the renaming of domain-joined workstations.
It's a two-step process: first you rename the computer, and then rename its OU/CN. netdom renamecomputer doesn't rename the AD object, and I assume that Rename-Computer doesn't either (please edit this answer if that's incorrect).
PowerShell
Rename-Computer
[ Get-ADComputer | ] Rename-ADObject
CMD
netdom renamecomputer
dsmove

Active Directory: Map a domain user with a username from ForeignSecurityPrinciple group and check if user is part of another specific group

I have this problem: we try to authenticate a user against an Active Directory that uses ForeignSecurityPrinciple to map users from different domains.
We have several groups that are stored inside a single domain and users that are coming from different domains.
The problem we have here is that we cannot get the real user name from ForeignSecurityPrinciple.
We tried to use the guidelines from here:
http://www.brandonclaps.com/?p=57
but with no luck.
When we tried to edit the entry for group that had 3 members, we found this next to the member field:
CN = S-1-5-21-other numbers, CN=ForeignSecurityPrinciple; DC=DomainName, DC=local
Do you have other solutions for retrieving the username against Active Directory using ForeginSecurityPrinciple ?
Is there any recommendation for using that?
Thanks a lot in advance

Can I create a new global security group with an existing name in Active Directory?

How can I create a global security group with a name of finance, seeing that I already have a user with that name in Active Directory. Is it possible?
You cannot have two objects of the same name in the same container - so you cannot create a group called Finance in the same container (OU) where the user Finance exists. Both user as well as group would be identified by
OU=Finance,OU=YourOU,OU=YourOtherOU,dc=YourCompany,dc=com
and that won't work - the fully distinguished bane (FQDN) of each object must be unique.
Other than that, there's a requirement that objects must have unique SAM Account Names - which by default are the same as the "display" name (Finance) - but can be set to something else.
So if your user is called Finance and has a SAM account name of Finance - then you should be able to create a global group called Finance (in a different OU/Container) by settings it's SAM account name to e.g. FinanceGroup or something like that.
You're not specifying what language/programming system you're using - if you're trying to create this group in C# / .NET 3.5 or higher, you could use code something like this:
using(PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
GroupPrincipal finGroup = new GroupPrincipal(ctx);
finGroup.DisplayName = "Finance";
finGroup.SamAccountName = "FinanceGroup";
finGroup.Save();
}

Resources