[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Schema & ldif of NDS4.x importing to openldap



Saurabh Bhardwaj wrote:
> 
> Hi
> 
> Has anybody tried importing schema and ldif file of Netscape Directory
> Server 4.x to openldap 2.x ??
> 
> Pl pass me the procedure/link to do so .
> 

I just submitted ITS #1013. See if that helps.


Markus
#!/bin/sh

TMP=/tmp/.$$

cat $1>$TMP

trap 'rm -f $TMP' 0 1 2 15


class="X"

while read i; do
	case $i in
	attri*)	COUNT=`echo $i | wc -w`
		echo $i | ( while read dummy name oid type opt; do

			if [ $COUNT -eq 4 -a "$type" = "single" ]; then
				type=$oid
				oid=""
				opt=single
			fi
			if [ $COUNT -eq 3 ]; then
				type=$oid
				oid=""
			fi

			while [ "$oid" != "" -a "` echo $oid | gawk -F '' '{ print $1 }' | tr -d '[0-9]'`" != "" ]; do
				name="$name' '$oid"
				oid=$type
				type=$opt
				read opt
			done

			echo "attributetype	( $oid"
			echo "	NAME ( '"$name"' )"

			case $type in
			int)    echo "	EQUALITY integerMatch"
				echo -n "	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27";;
			ces)    echo "	EQUALITY caseExactMatch"
				echo "	SUBSTR caseExactSubstringsMatch"
				echo -n "	SYNTAX 1.3.6.1.4.1.1466.115.121.1.15";;
			cis)    echo "	EQUALITY caseIgnoreMatch"
				echo "	SUBSTR caseIgnoreSubstringsMatch"
				echo -n "	SYNTAX 1.3.6.1.4.1.1466.115.121.1.15";;
			dn)     echo "	EQUALITY distinguishedNameMatch"
				echo -n "	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12";;
			bin)    echo "	EQUALITY bitStringMatch"
				echo -n "	SYNTAX 1.3.6.1.4.1.1466.115.121.1.6";;
			tel)    echo "	EQUALITY telephoneNumberMatch"
				echo "	SUBSTR telephoneNumberSubstringsMatch"
				echo -n "	SYNTAX 1.3.6.1.4.1.1466.115.121.1.50";;
			esac
			if [ "$opt" = "single" ]; then
				echo; echo -n "	SINGLE-VALUE"
			fi
			echo " )"; echo
			opt=""
		done ) ;;

	object*)	sup="X"; must='X'; may='X'
			name=`echo $i | gawk '{ print $NF }'`

			read j

			while [ -n "$j" ]; do
				case $j in
				oid*)	oid=`echo $j | gawk '{ print $NF }'`;;
				super*)	sup=`echo $j | gawk '{ print $NF }'`;;
				requi*)	must="("; count=0
					read k
					while [ "`echo $k | gawk -F '' '{ print $NF}'`" = "," ]; do
						k=`echo $k | tr -d ','`
						len=`echo $k | wc -c`; count=`expr $count + $len + 2`
						must="$must $k \$"
						if [ $count -gt 60 ]; then
							must="$must
		"
							count=0
						fi
						read k
					done
					must="$must $k )";;
				allow*)	may="("; count=0
					read k
					while [ "`echo $k | gawk -F '' '{ print $NF}'`" = "," ]; do
						k=`echo $k | tr -d ','`
						len=`echo $k | wc -c`; count=`expr $count + $len + 2`
						may="$may $k \$"
						if [ $count -gt 60 ]; then
							may="$may
		"
							count=0
						fi
						read k
					done
					may="$may $k )";;
					
				esac

				read j
			done

			echo -n "objectclass ( "$oid "NAME '"$name"'"
			if [ "$class" != "X" ]; then
				case $class in
				auxiliary)	echo -n " AUXILIARY";;
				abstract)	echo -n " ABSTRACT";;
				*)		echo -n " STRUCTURAL";;
				esac
			fi
			if [ "$sup" != "X" ]; then
				echo; echo -n "	SUP $sup"
			fi
			if [ "$must" != "X" ]; then
				echo; echo -n "	MUST $must"
			fi
			if [ "$may" != "X" ]; then
				echo; echo -n "	MAY $may"
			fi

			echo " )"; echo
			class="X";;

	*)		if [ "`echo $i | gawk '{ print $2,$3 }' | tr -d ':'`" = "class type" ]; then
				class=`echo $i | gawk '{ print $NF }'`
			fi
			echo $i;;
	esac
done < $TMP

begin:vcard 
n:Storm;Markus
tel;fax:++49 +5241 80-67867
tel;work:++49 +5241 80-7867
x-mozilla-html:FALSE
org:mediaWays GmbH;NMW-T
adr:;;Postfach 185;Guetersloh;;33311;Germany
version:2.1
email;internet:Markus.Storm@mediaWays.net
x-mozilla-cpt:ils.mediaways.net;23744
fn:Markus Storm
end:vcard