AD Ou structure generated by Adsync process WIN2K AllGroups Security Groups Alphabetical Groups Students% first char % Grouping Groups Courses groups %course_code %-%course_number%-% section_number%-% crn%-% term_code_key %-% instructor_email% DEPARTMENTS-STF %Department name%-stf FACULTIES-STD %Faculty name%-std MAJORS-STD %Faculty name%-%major%-%graduateflag% Graduates prmedicine undergraduates notstudents MCAllStaff MCAllResidents MCAllinterns AllACADstaff students AllUsers NON-ACTIVE-USERS STD DISABLED STUDENT ACCOUNTS STF DISABLED STAFF ACCOUNTS NON-Students %DEPARTMENT NAME% ACTIVE STAFF ACCOUNTS Students %FACULTY NAME% %MAJOR NAME% %GRAD FLAG% ACTIVE STUDENT ACCOUNTS
Adsync.exe scheduled job @ 4 hours interval supplied with the number of days for wich to query NETDB as arguments. Create user buffer list from oracle NETDB ID,login,first_name,last_name,PERS_TYPE,DEPT_C OLL_DESC,MAJOR_DESC,active,box,extension,cate gory,barcode,graduate,email,employment_date,p ROLE,MANAGED_BY,LOCATION,coll_code,old_uid Open the buffer user list and processes it line by line: While Not buffer user list At End Of file Each line is split into an array and values are assigned: the values are assigned from the array to the variables and global indexes are reset Fix special and empty conditions: Take care of department and majors names that contain non-allowed characters(,/().: ) take care of empty departments, majors names and graduate flag and cost centers Check If Username <> BLANK CHECK if user already exists In AD CHECK if Old User id from oracle <> BLANK update_existing_user CHECK if Old User id already Exists In AD If any called function has generated an error Log event into No username log Log event into processed users log rename_user create_new_user create_new_user Send email to aubede containing the error Loop If an error occurred in this function itself Call the adsi error msg generating function Send email to aubede containing the error Exit
create_new_user Set MAIN variables UserCn = "CN=" + Username UserPrincipalName = Username + "@win2k.aub.edu.lb" IsAccountFirstCreation = "Y" If User New State is set to Active SetuserOUforactive SetuserOUfordisabled setuserhomepath setuserinfo If User New State is set to Active createnewhomefolder setusergroups Set user.accountdisabled = Set user.accountdisabled = user.setinfo If Error occurred Ture Call adsierr("create_new_user") Log event into newly created users log
update_existing_user Set UserCn = "CN=" + Username If user has not been renamed SET UserAdsPath & OldHomeDriveLocation & intuac To values retrieved from active directory representing current status and information also SET current_activ_stat = ture if user is disabled setuserhomepath Is User New State is set to Active createnewhomefolder setuserinfo Is User New State is set to Active SetuserOUforactive SetuserOUfordisabled clearusergroupinggroups (clears users group membership to any group in,ou=security groups) If PersonType is student clearuseralphagroups (clears users group membership to any group in ou=alphabetical groups,ou=security groups) If User New State is set to Active setusergroups Set user.accountdisabled = Set user.accountdisabled = user.setinfo If Error occurred adsierr("update_existing_user")
setuserhomepath If PersonType = students true NewHomeDriveLocation = "\\win2k.aub.edu.lb\files\home" & UCase(UserNameFirstChar) & "\" + Username FTPRootdir = "\\win2k.aub.edu.lb\files\home" & UCase(UserNameFirstChar) & "\" If PersonType = Intern or resident true If Category = "M" Then ' AUH staff ' NewHomeDriveLocation = "\\win2k.aub.edu.lb\ files\int-rs Homes\" + Username FTPRootdir = "\\win2k.aub.edu.lb\files\int-rs Homes\" true NewHomeDriveLocation = "\\win2k.aub.edu.lb\files\ MC home Folders\" + Username FTPRootdir = "\\win2k.aub.edu.lb\files\mc home folders\" Else ' AUB Staff ' NewHomeDriveLocation = "\\win2k.aub.edu.lb\files\institutional Data\" + Username FTPRootdir = "\\win2k.aub.edu.lb\files\institutional Data\"
Createnewhomefolder If OldHomeDriveLocation <> NewHomeDriveLocation If NewHomeDrive does not exist Create home Folder If user is changing status from disabled to enabled If PersonType is student If NewHomeDrive does not exist Create hidden favorites folder recreate home folder for user since if it was deleted during the cleaning procedure If PersonType is student sethomefolderpermissions Create hidden favorites folder If OldHomeDriveLocation <> BLANK and Old Home folder exists sethomefolderpermissions Write robocopy command to log file of home transfer list Execute robocopy to move content to new home adsierr("createnewhomefolder")
Sethomefolderpermissions If PersonType = students true Set admingroup = "allhomeadmins" If PersonType = Intern or resident true Set admingroup = "MChomeadmins" If Category = "M" Then ' AUH staff ' true Else ' AUB Staff ' Set admingroup = "InstitutionalDataAdmins" Set admingroup = "MChomeadmins" Write xcacls command command to log file xcacls.log.txt Execute xcacls to set appropriate permissions on home folder adsierr("sethomefolderpermissions")
setuserinfo Is IsAccountFirstCreation flag set to "Y" false Create user in finaloupath SET THE FOLLOWING USER PROPERTIES "samaccountname","userprincipalname", Set "msnpallowdialin" to "altsecurityidentities", "Kerberos:" Username@AUB.EDU.LB" user.setinfo Set user object to found user path in MAIN then clear "profilepath" If AubManager <> "" Then search AD for the managers username to get the DN of his ACCOUNT Manager username not found Manager username found LOG EVENT invalidmanagerlog SET THE FOLLOWING USER PROPERTIES "homedirectory", "msiis-ftpdir", "msiis- FTPRoot", "HomeDrive", "description", "givenname", "sn" LastName, "displayname", "AUB-ID", "AUB-Employment-Date", "AUB- Prole", AUB-PersonType, "AUB-Location", "mail", "telephonenumber", "postofficebox", manager user.setinfo SET THE FOLLOWING USER PROPERTIES "homedirectory", "msiis-ftpdir", "msiis- FTPRoot", "HomeDrive", "description", "givenname", "sn" LastName, "displayname", "AUB-ID", "AUB-Employment-Date", "AUB- Prole", AUB-PersonType, "AUB-Location", "mail", "telephonenumber", "postofficebox", CLEAR MANAGER ATTRIBUTE user.setinfo Is IsAccountFirstCreation flag set to "Y" Set password to random If error occurred in this function adsierr("setuserinfo")
SetuserOUfordisabled If PersonType = student Set finaloupath = "OU=STD,ou=NON-ACTIVE-USERS,ou=allusers,dc=win2k,dc=aub,dc=edu,dc=lb" finaloupath = "OU=STF,OU=NON-ACTIVE-USERS,ou=allusers,dc=win2k,dc=aub,dc=edu,dc=lb" Is IsAccountFirstCreation flag set to "N" Is IsAccountFirstCreation flag set to "N" Move User account Into THE finaloupath Move User account Into THE finaloupath If error occurred in this function adsierr("setuseroufordisabled")
SetuserOUforactive If PersonType = student Set Finaloupath = "OU=" & GraduateFlag & ",OU=" & Major & ",OU=" & Department & ",OU=Students,OU=AllUsers,DC=win2k,DC=aub,DC= edu,dc=lb" And set finaluserpath = "LDAP://" & UserCn & "," & finaloupath Set Finaloupath = "OU=" & Department & ",OU=NON- Students,OU=AllUsers,DC=win2k,DC=aub,DC=edu, DC=lb" And set finaluserpath = "LDAP://" & UserCn & "," & finaloupath Is there a change in user OU location finaluserpath <> UserAdsPath Is there a change in user OU location finaluserpath <> UserAdsPath checkousexistense checkousexistense Is IsAccountFirstCreation flag set to "N" Is IsAccountFirstCreation flasg set to "N" Move User account Into THE finaloupath Move User account Into THE finaloupath If error occurred in this function adsierr("setuserouforactive")
checkousexistense If PersonType is Staff check if department OU exists check if CostCenter/CollegeCode number is in any of the existing Ous descriptions (student) Create Department organizationalunit with "description"=costcenter/collegecode rename the OU and assosiated GROUP to the new department name relevant for this CostCenter/CollegeCode as this code should be unique update OU description=costc enter/collegecode check if faculty OU exists true Create faculty organizationalunit with "description"=costcenter/collegecode update OU description=costc enter/collegecode check if MAJOR OU exists Create MAJOR organizationalunit check if gruaduateflag OU exists (UG,GR,PR) Create gruaduateflag organizationalunit If error occurred in this function adsierr("checkousexistense")
setusergroups checkgroupinggroupsexistense If PersonType is "STUDENT = STAFF Add to group CN=(Department) & "-std" in OU=FACULTIES-STD,OU=grouping groups Add to group CN=(Department) & "-stf" in OU=DEPARTMENTS-STF,OU=grouping groups Add to group CN =students in Add to group CN =notstudents in Add to alpha group CN ="Students" & (FirstChar in UserName) in ou=alphabetical groups TRUE Check if user Category = AUH STAFF Add to group cn=(department) & "-" & (Major) & "-" & (GraduateFlag) In OU=MAJORS-STD,ou=grouping groups, Add to group CN =MCAllStaff in FALSE UG CHECK GRADFLAG PR Other Other IT CHECK PersonType AC GR RS Add to group CN =undergraduates in Add to group CN =graduates in Add to group CN =prmedicine in Add to group CN =MCAllinterns in Add to group CN =MCAllResidents in Add to group CN =AllACADstaff in If error occurred in this function adsierr("setusergroups")
checkgroupinggroupsexistense If PersonType is Staff (student) check if department group (Department & "-STF") exists In OU=DEPARTMENTS-STF,OU=grouping groups check if faculty group (Department & "-STD") exists In OU=FACULTIES-STD,OU=grouping groups Create FACULTY group true Create DEPARTMENT group check if MAJOR group (Department & "-" & Major & "-" & GraduateFlag) exists In OU=MAJORS-STD, Create MAJOR group If error occurred in this function adsierr("checkgroupinggroupsexistense")
fix_special_and_empty_conditions If CostCenterCollegeCode = "" CostCenterColleg ecode = "UNDECLARED" If PersonType IS STUDENT (staff) If GraduateFlag = "" If Department = "" GraduateFlag = "UND" If Department = "" Department = "NO DEPARTMENT SPECIFIED" If Major = "" Department = "NO COLLEGE DESIGNATED" If Major = "" Major = "No major Designated" Major = "MAJORLESS" Take care of department and majors names that contain non-allowed characters : /,. ( )
rename_user Rename user object to its new CN name Fix all relevant attributes with the new name "samaccountname" "userprincipalname" "altsecurityidentities" Check if current home folder exists false setuserhomepath setuserhomepath Check if the new home folder path has changed Is ActiveFlag = "Y" Rename the users folder only Set the varaible OldHomeDriveLocation = to the existing current home createnewhomefolder createnewhomefolder Set "homedirectory" attribute in AD Connect to oracle NETDB and set the field ucr_ads_processed for the current date when the user was renamed in AD Log event in renamed users log Set Rename_stat = "Y" update_existing_user If error occurred in this function adsierr("rename_user")
adsierr Receive the name of the function where the error originated Generate an error message containing all user info and where the error occurred and error type append to log errorlog.txt the message Append the message to the email body of the mail that will be sent at the end of the process Set globalerror flag = 1