Tag Archives: AD

Problem writing/wrapping files under folder using perl

By Optimus81

I have a script which generates env setup xml file by reading path.It read the path and checks if there is any file/dir present recurseively.
If a file is found under sub directory then it will read the file and the values from the file are passed to generate xml format.

Problem is if i have a file in sub directory, then in xml format, these file information should come under sub directory name but current script
write all the file information under only main sub directory level2.
Ex :
Path : C:SDSetupData
In the above path, there will sub dir level1 : UAINI
C:SDSetupDataUAINI
under this level1, there will another level2 of sub dir : Base
C:SDSetupDataUAINIBase
under this level2, there will 3 sub dir’s level3 :

Code:

A1 : 1-A.bat,1-AD.bat files
B2 : 2-BDD.bat, 2-BEE.bat files
W1 : 1-WM.bat, 2-WMA.bat files


each of these sub dir’s will have 1 or more files
file content will be:

Code:

start putty -ssh -P 22 10.24.04.20A -Q root -pw olp.ikmj


now after running the main script,i get the xml format with the content under Base dir as container(level2). Instead, should get xml format
with having 3 containers and each container having sub dir’s level3 name and it’s file content.

Code:

#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
my $basedir = "C:/SD/Setup/Data/";
my $envname = "HMDS_EnvSetup";
my $counter;
my @basedir;
open( my $resultfile, '>', 'C:SDSetupResultsresultfile.dat' ) or die "resultfile.dat: $!";
# the next bit should only be written one time per xml output file:
print $resultfile <<EOH;






EOH
my @containers;
my $indent = '';
#print scalar(@containers);
find( &wanted, $basedir );
if ( @containers ) {
for ( 1 .. $#containers ) {
print $resultfile "$indentn";
chop $indent;
}
}
print $resultfile "nn";
sub wanted {
return if ( /^..?$/ );
if ( -d ) {
my ( $root, @levels ) = split m{/}, $File::Find::dir;
print "levels are :@levelsn";
print "Containers are : @containersn";
if ( @levels >= @containers ) { # push one level deeper
$indent .= " ";
print $resultfile "$indentn";
$counter++;
}
elsif ( @levels <= @containers ) { # pop out one level
print $resultfile "$indentn";
chop $indent;
}
elsif ( $levels[-1] ne $containers[-1] ) { # same level, different path
print $resultfile "$indentn";
print $resultfile "$indentn";
}
@containers = @levels;
}
elsif ( -f _ and -s _ ) {
process_file();
}
}
sub process_file {
my $filename = $_;
open my $fh, '<', $filename or die "$File::Find::name : $!n";
my @linecolumns;
while () {
chomp;
s/ /,/g;
@linecolumns=split(',',$_);
}
print $resultfile <<ETX
$indent
$indent
$indent $filename
$indent SSH
$indent $linecolumns[5]
$indent $linecolumns[4]
$indent Default Settings
$indent $linecolumns[6] $linecolumns[7] $linecolumns[8] $linecolumns[9]
$indent
$indent
$indent
$indent
$indent
$indent
$indent
$indent
ETX
;
}


now getting output as :

Code:







1-WM.bat
SSH
19.20.54.21
221
Default Settings
-l root -pw uy.ju

2-WMA.bat
SSH
19.20.54.21
221
Default Settings
-l root -pw uy.ju

2-BBD.bat
SSH
98.28.54.21
27
Default Settings
-l root -pw direct.nA

2-BBE.bat
SSH
18.38.58.88
28
Default Settings
-l root -pw direct.2A

1-A.bat
SSH
10.24.04.20A
22
Default Settings
-l root -pw olp.ikmj

1-AD.bat
SSH
09.25.05.10B
11
Default Settings
-l root -pw llb.ujyh


Attached png file to show how current output looks like.

Instead am trying to get like this : please note i added container tag manually here to get each sub dir’s level3 dir name/wrapper.

Code:







#-----This added manually

1-WM.bat
SSH
19.20.54.21
221
Default Settings
-l root -pw uy.ju

2-WMA.bat
SSH
19.20.54.21
221
Default Settings
-l root -pw uy.ju

#-----This added manually

#-----This added manually

2-BBD.bat
SSH
98.28.54.21
27
Default Settings
-l root -pw direct.nA

2-BBE.bat
SSH
18.38.58.88
28
Default Settings
-l root -pw direct.2A

#-----This added manually

#-----This added manually

1-A.bat
SSH
10.24.04.20A
22
Default Settings
-l root -pw olp.ikmj

1-AD.bat
SSH
09.25.05.10B
11
Default Settings
-l root -pw llb.ujyh

#-----This added manually


Source: FULL ARTICLE at The UNIX and Linux Forums

UNIX authentication strategy – LDAP or AD

By x96riley3

We are looking at using Tivoli Directory Server (LDAP) or Active Directory 2003 for authentication. I wanted to get some feedback from the community. Our goal is to do it the simplest, easiest, and cheapest way that allows for centralized user authentication. We are mainly an AIX environment with some Red Hat and Suze mixed in.

All advice greatly appreciated.

Source: FULL ARTICLE at The UNIX and Linux Forums

How to Map AD groups to Samba share?

By sunnysthakur

I am setup a samba share server which is authenticating from Active Directory.

I am able to access the share with AD user but not able to access when group defined in “valid users” parameters.

below are the steps i performed.

In smb.conf

[global]
workgroup = QASLABS
password server = WIN-60I6H2BG237.qaslabs.net
realm = QASLABS.NET
preferred master = no
security = ADS
idmap backend = ad
idmap uid = 100-20000000
idmap gid = 100-20000000
winbind separator = +
template shell = /bin/bash
winbind use default domain = true
winbind offline logon = false
preferred master = no
server string = Linux Test Machine
encrypt passwords = yes
log level = 3
log file = /var/log/samba/%m
max log size = 50
printcap name = cups
printing = cups
winbind enum users = yes
winbind enum groups = yes
winbind use default domain = yes
winbind nested groups = yes
netbios name = smbad
hosts allow = 127.0.0.1 192.16.17.0/24
passdb backend = tdbsam
template homedir = /home/%U
winbind nss info = rfc2307

[Data]
comment = Directory for storing Data
path= /opt/data
valid users = @NETWORK+itadmin NETWORK+testadmin
#valid users = @”QASLABS.NET\itadmin”
writeable = yes
browseable=yes
create mask = 775
directory mask = 775
hosts allow = 127.0.0.1 192.16.17.0/24

In /etc/nsswitch.conf

passwd: files winbind
shadow: files winbind
group: files winbind
hosts: files dns wins
bootparams: nisplus [NOTFOUND=return] files
ethers: db files
netmasks: files
networks: files
protocols: db files
rpc: files
services: files
netgroup: files
publickey: nisplus
automount: files
aliases: files nisplus

On executing the wbinfo -u i am getting the user list from AD

[root@smbad ~]# wbinfo -u
administrator
guest
krbtgt
testdev
testadmin
testhr
testqa
testit
testcmt
testsupp
testituser

On executing the wbinfo -u i am getting the user list from AD. But groups i created on AD is not displaying in this list [i.e itadmin]

[root@smbad ~]# wbinfo -g
BUILTIN+administrators
BUILTIN+users
SMBAD+itadmin
domain computers
domain controllers
domain admins
domain users
domain guests
group policy creator owners
read-only domain controllers
dnsupdateproxy
cert publishers
ras and ias servers
allowed rodc password replication group
denied rodc password replication group
dnsadmins
schema admins
enterprise admins
enterprise read-only domain controllers

Please help on how to map AD group to samba so that group permissions can be setup on samba

Source: FULL ARTICLE at The UNIX and Linux Forums