Let private generation use Account class
[mirror/userdir-ldap.git] / ud-generate
index 943da31..1a40f67 100755 (executable)
@@ -31,6 +31,7 @@
 import string, re, time, ldap, getopt, sys, os, pwd, posix, socket, base64, sha, shutil, errno, tarfile, grp
 from userdir_ldap import *
 from userdir_exceptions import *
+import UDLdap
 try:
    from cStringIO import StringIO
 except ImportError:
@@ -580,10 +581,11 @@ def GenMarkers(File):
      
       # Write out the position for each user
       for x in PasswdAttrs:
-         if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0:
+         a = UDLdap.Account(x[0], x[1])
+         if not ('latitude' in a and 'longitude' in a):
             continue
          try:
-            Line = "%8s %8s \"\""%(DecDegree(GetAttr(x, "latitude"), 1), DecDegree(GetAttr(x, "longitude"), 1))
+            Line = "%8s %8s \"\""%(a.latitude_dec(True), a.longitude_dec(True))
             Line = Sanitize(Line) + "\n"
             F.write(Line)
          except:
@@ -606,15 +608,13 @@ def GenPrivate(File):
      
       # Write out the position for each user
       for x in DebianDDUsers:
-         if x[1].has_key("privateSub") == 0:
+         a = UDLdap.Account(x[0], x[1])
+         if not a.is_active_user():
             continue
-     
-         # If the account has no PGP key, do not write it
-         if x[1].has_key("keyFingerPrint") == 0:
+         if not 'privateSub' in a:
             continue
-     
          try:
-            Line = "%s"%(GetAttr(x, "privateSub"))
+            Line = "%s"%(a['privateSub'])
             Line = Sanitize(Line) + "\n"
             F.write(Line)
          except: