Hi,
I'm not an expert in AWK, but I've been advised awk could help with this problem...
I have the following file I'd been trying to merge with SQL within a database, basically, I've had to merge AD users and group information, which in SQL is not an issue. However, it's producing me output (for many users, that looks like this;
| AccountDisabled | CanonicalNameUser | City | Comment | CommonName | Company | Country | CreationDate | Department | Description | DisplayName | DistinguishedName | GroupName |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G1 |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G2 |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G3 |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G4 |
| FALSE | client.local/client/Accounts/user2 | Town | | user2 | company name | | 02/12/2009 17:02 | Department1 | | User 2 | CN=user2,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7 |
| FALSE | client.local/client/Accounts/user3 | Town | | user3 | company name | | 02/12/2009 17:02 | Department1 | | User 3 | CN=user3,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7 |
| FALSE | client.local/client/Accounts/user3 | Town | | user2 | company name | | 02/12/2009 17:02 | Department1 | | User 2 | CN=user2,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G8 |
So you can see, that it's listing me all all groups, with the users also.
What I wanted to do in SQL was produce output like;
FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G1,Grp_G2,Grp_G3,Grp_G4 |
| FALSE | client.local/client/Accounts/user2 | Town | | user2 | company name | | 02/12/2009 17:02 | Department1 | | User 2 | CN=user2,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7 |
| FALSE | client.local/client/Accounts/user3 | Town | | user3 | company name | | 02/12/2009 17:02 | Department1 | | User 3 | CN=user3,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7,Grp_G8 |
So basically, I need to scan the file for the column DistinguishedName e.g. CN=user1,OU=Accounts,OU=Client,DC=client,DC=local
If it appears in the subsequent rows, merge the attribute contained in GroupName into the first Groupname Value
If it doesn't appear in the subsequent rows, then just continue, but also put this into the output
I'm not an expert in AWK, but I've been advised awk could help with this problem...
I have the following file I'd been trying to merge with SQL within a database, basically, I've had to merge AD users and group information, which in SQL is not an issue. However, it's producing me output (for many users, that looks like this;
| AccountDisabled | CanonicalNameUser | City | Comment | CommonName | Company | Country | CreationDate | Department | Description | DisplayName | DistinguishedName | GroupName |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G1 |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G2 |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G3 |
| FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G4 |
| FALSE | client.local/client/Accounts/user2 | Town | | user2 | company name | | 02/12/2009 17:02 | Department1 | | User 2 | CN=user2,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7 |
| FALSE | client.local/client/Accounts/user3 | Town | | user3 | company name | | 02/12/2009 17:02 | Department1 | | User 3 | CN=user3,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7 |
| FALSE | client.local/client/Accounts/user3 | Town | | user2 | company name | | 02/12/2009 17:02 | Department1 | | User 2 | CN=user2,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G8 |
So you can see, that it's listing me all all groups, with the users also.
What I wanted to do in SQL was produce output like;
FALSE | client.local/client/Accounts/user1 | Town | | user1 | company name | | 02/12/2009 17:02 | Department1 | | User 1 | CN=user1,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G1,Grp_G2,Grp_G3,Grp_G4 |
| FALSE | client.local/client/Accounts/user2 | Town | | user2 | company name | | 02/12/2009 17:02 | Department1 | | User 2 | CN=user2,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7 |
| FALSE | client.local/client/Accounts/user3 | Town | | user3 | company name | | 02/12/2009 17:02 | Department1 | | User 3 | CN=user3,OU=Accounts,OU=Client,DC=client,DC=local | Grp_G7,Grp_G8 |
So basically, I need to scan the file for the column DistinguishedName e.g. CN=user1,OU=Accounts,OU=Client,DC=client,DC=local
If it appears in the subsequent rows, merge the attribute contained in GroupName into the first Groupname Value
If it doesn't appear in the subsequent rows, then just continue, but also put this into the output